Imagine you're reading a sentence and need to verify that any numbers mentioned are in strictly ascending order from left to right. This is exactly what this problem asks you to do!
Given a string s representing a sentence, you need to check if all the numbers in the sentence are strictly increasing from left to right. A sentence consists of tokens separated by single spaces, where each token is either:
- A positive number (digits 0-9, no leading zeros)
- A word (lowercase English letters)
Example: In the sentence "a puppy has 2 eyes 4 legs", we have numbers 2 and 4. Since 2 < 4, the numbers are in ascending order, so we return true.
Goal: Return true if all numbers in the sentence are in strictly ascending order, false otherwise. If there's only one number or no numbers, return true.
Input & Output
Constraints
- 3 โค s.length โค 200
- s consists of lowercase English letters, spaces, and digits from 0 to 9
- The number of tokens in s is between 2 and 100
- The tokens are separated by a single space
- No leading or trailing spaces
- Numbers have no leading zeros