[LeetCode]#2124. Check if All A’s Appears Before All B’s

Input: s = "aaabbb"
Output: true
Explanation:
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.
  1. check pattern “ba” is matched with s.
  2. If yes, return False. Else, return True.
class Solution:
def checkString(self, s):
if "ba" in s:
return False
else:
return True

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fatboy Slim

Fatboy Slim

Interesting in any computer science.