[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

--

--

--

Interesting in any computer science.

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

Recommended from Medium

Database Hacking Part — 2

So Easy MicroPython — MQTT ThingSpeak, IoT

The Seven Habits of Highly Effective Scientific Programming

How to create SNS notification for API gateway monitoring using CloudFormation

This blog explained about how to monitor API gateway error using SNS. This full stack can be created using CloudFormation template.

Find a Cocktail — CLI Project

The Difference Between Compiled and Interpreted Languages

Testing 1, 2, 3: Why Everyone Should Consider Automated Three-Layer Application Testing

Rust Guide: Sum-Check protocol

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 Patterns Adventure 32 — Backspace String Compare

Leetcode 534 Game Play Analysis III without sum window function

[LeetCode]#2114. Maximum Number of Words Found in Sentences

Leetcode problem: Solving Questions With Brainpower