출처 : https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/
Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.

class Solution {
public boolean checkString(String s) {
List<Integer> arrA = new ArrayList<>();
List<Integer> arrB = new ArrayList<>();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'a') {
arrA.add(i);
} else {
arrB.add(i);
}
}
if (arrA.size() == 0 || arrB.size() == 0) return true;
else if (arrA.get(arrA.size() - 1) > arrB.get(0)) {
return false;
}
return true;
}
}