Leetcode Note: Go - Check if All A's Appears Before All B's

Check if All A’s Appears Before All B’s - LeetCode
https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/

  • Go 言語で取り組んだメモ

回答

Python/JS/Go/C++ O(n) violation checking [w/ Example] - Check if All A’s Appears Before All B’s - LeetCode
https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/solutions/1661920/python-js-go-c-o-n-violation-checking-w-example/

func checkString(s string) bool {
    
    // 'a' cannot come after 'b'
    violation := "ba"
    
    return strings.Count(s, violation) == 0
}