728x90
https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/
class Solution:
def areNumbersAscending(self, s: str) -> bool:
sentence = s.split(' ')
before = -1
for token in sentence:
if token.isdigit():
if int(token) > before:
before = int(token)
else:
return False
return True
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 2278. Percentage of Letter in String (0) | 2023.08.16 |
---|---|
[Leetcode] 175. Combine Two Tables (0) | 2023.08.16 |
[Leetcode] 27. Remove Element (0) | 2023.08.11 |
[Leetcode] 383. Ransom Note (0) | 2023.08.11 |
[Leetcode] 511. Game Play Analysis I (0) | 2023.08.10 |