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
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;
}
}