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.

&nbsp;
Example 1:

Input: s = "aaabbb"
Output: true
Explanation:
The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
Hence, every 'a' appears before every 'b' and we return true.


Example 2:

Input: s = "abab"
Output: false
Explanation:
There is an 'a' at index 2 and a 'b' at index 1.
Hence, not every 'a' appears before every 'b' and we return false.


Example 3:

Input: s = "bbb"
Output: true
Explanation:
There are no 'a's, hence, every 'a' appears before every 'b' and we return true.


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 100
	s[i] is either 'a' or 'b'.


class Solution:
    def checkString(self, s: str) -> bool:
        if "ba" in s:
            return False
        else:
            return True
class Solution {
    public boolean checkString(String s) {
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'b'){
                for(int j = i+1; j < s.length(); j++){
                    if(s.charAt(j) == 'a'){
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
class Solution {
public:
	bool checkString(string s) {
		for(int i = 1; i < s.size(); i++){
			if(s[i - 1] == 'b' && s[i] == 'a'){
				return false;
			}
		}
		return true;
	}
};
var checkString = function(s) {
    
    // a cannot come after b
    let violation = "ba";
    
    return s.indexOf(violation, 0) == -1;
};
Check if All A's Appears Before All B's