Leetcode in Java && Oracle
421 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-01-05_01-14-41.png
34.9 KB
#N2124. Check if All A's Appears Before All B's
problem link

#solution
class Solution {
public boolean checkString(String s) {
boolean isFound = false;

for(int i=0; i<s.length(); i++){
if(s.charAt(i) == 'b')
isFound = true;

if(isFound && s.charAt(i) == 'a')
return false;
}

return true;
}
}