Practice Check if Numbers Are Ascending in a Sentence
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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 lowercase English letters. Given a string s representing a sentence, you need to check if all the numbers in s are strictly increasing from left to right (i.e., other than the last number, each number is strictly smaller than the number on its right in s). Return true if so, or false otherwise.
Source: Check if Numbers Are Ascending in a Sentence on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "1 box has 3 blue 4 red 6 green and 12 yellow marbles"
true
# Example 2
s = "hello world 5 x 5"
false
# Example 3
s = "sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s"
false
Constraints
Related LeetCode Problems
Practice more problems similar to Check if Numbers Are Ascending in a Sentence.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.