Skip to content

Commit f92f440

Browse files
authored
Create Check if All A's Appears Before All B's.java
1 parent d8a6a1f commit f92f440

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public boolean checkString(String s) {
3+
boolean aFound = false;
4+
boolean bFound = false;
5+
for (int i = 0; i < s.length(); i++) {
6+
if (s.charAt(i) == 'a') {
7+
if (bFound) {
8+
return false;
9+
}
10+
aFound = true;
11+
} else {
12+
bFound = true;
13+
}
14+
}
15+
return true;
16+
}
17+
}

0 commit comments

Comments
 (0)