JuniorString
Check if All A's Appears Before All B's
Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.
Example 1
Input
s = "aaabbb"Output
trueThe 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5, so every 'a' appears before every 'b'.
Example 2
Input
s = "abab"Output
falseThere is an 'a' at index 2 and a 'b' at index 1, so not every 'a' appears before every 'b'.
Constraints
- 1 <= s.length <= 100
- s[i] is either 'a' or 'b'.