[LeetCode]#2124. Check if All A’s Appears Before All B’s
Environment: Python 3.8
Key technique: if
Given a string
s consisting of only the characters
true if every
'a' appears before every
'b' in the string. Otherwise, return
Input: s = "aaabbb"
The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
Hence, every 'a' appears before every 'b' and we return true.
- check pattern “ba” is matched with s.
- If yes, return False. Else, return True.
def checkString(self, s):
if "ba" in s: