Practice Check if All A's Appears Before All B's
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
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.
Source: Check if All A's Appears Before All B's on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "aaabbb"
Output
true
# Example 2
Input
s = "abab"
Output
false
# Example 3
Input
s = "bbb"
Output
true
Constraints
1 <= s.length <= 100
s[i] is either 'a' or 'b'.
Related LeetCode Problems
Practice more problems similar to Check if All A's Appears Before All B's.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.