/**
* Problem: LeetCode 2124 - Check if All A's Appears Before All B's
* Difficulty: Easy
* Language: Java
* Author: CodeByTushu
*/
class Solution {
public boolean checkString(String s) {
// Agar string me kahin bhi "ba" substring exist karti hai,
// iska matlab koi 'a' kisi 'b' ke baad aaya hai.
return !s.contains("ba");
}
}
"""
Problem: LeetCode 2124 - Check if All A's Appears Before All B's
Difficulty: Easy
Language: Python 3
Author: CodeByTushu
"""
class Solution:
def checkString(self, s: str) -> bool:
# Agar "ba" substring present hai, toh 'a' kisi 'b' ke baad appear ho raha hai
return "ba" not in s
/**
* Problem: LeetCode 2124 - Check if All A's Appears Before All B's
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
#include <string>
using namespace std;
class Solution {
public:
bool checkString(string s) {
// Agar string me "ba" substring nahi milti (find returns npos), toh true
return s.find("ba") == string::npos;
}
};
/**
* Problem: LeetCode 2124 - Check if All A's Appears Before All B's
* Difficulty: Easy
* Language: JavaScript
* Author: CodeByTushu
*/
/**
* @param {string} s
* @return {boolean}
*/
var checkString = function(s) {
// Agar "ba" substring present nahi hai toh return true
return !s.includes("ba");
};