https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/description/
Check if Numbers Are Ascending in a Sentence - LeetCode
Check if Numbers Are Ascending in a Sentence - A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lo
leetcode.com
1
2
3
4
5
6
7
8
9
10
11
12
13
|
class Solution:
def areNumbersAscending(self, s: str) -> bool:
nums = []
for i in s.split():
if i.isdigit():
nums.append(int(i))
answer = True
for i in range(1, len(nums)):
if nums[i - 1] >= nums[i]:
answer = False
return answer
return answer
|
cs |
크게 어려운 문제는 아니였는데 line6에서 type casting 해주셔야합니다!!
It wasn't a very difficult problem, but you have to type cast on line6!!
반응형
'python-algorithm' 카테고리의 다른 글
백준 27219 Робинзон Крузо (0) | 2023.01.16 |
---|---|
leetcode 1446. Consecutive Characters (0) | 2023.01.14 |
leetcode 191. Number of 1 Bits (0) | 2023.01.13 |
leetcode 2138. Divide a String Into Groups of Size k (0) | 2023.01.12 |
leetcode 2180. Count Integers With Even Digit Sum (0) | 2023.01.12 |
댓글