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

Input: s = "aaabbb"
Output: true
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
return True

Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How-to Change Sitecore Website Host Name

AWS CSA-A Exam — Nervous Final Reading

Pitfalls of Python Lists

3 Big Reasons to Modernize SAP® ArchiveLink

Factory Pattern & Abstraction in Python

A Christmas Miracle?

Mindset Over Madness

230. Kth Smallest Element in a BST

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.

More from Medium

[LeetCode]#2108. Find First Palindromic String in the Array

LeetCode Patterns Adventure 3— Find All Numbers Disappeared in an Array

Python TreeMap

Leetcode 534 Game Play Analysis III without sum window function