One line Java solution without Regex


  • 4

    I'm using two simple checks:

    • String doesn't contains LLL.
    • The first occurrence of A is equals to the last occurrence of A.
    public boolean checkRecord(String s) {
        return !s.contains("LLL") && (s.indexOf("A") == s.lastIndexOf("A"));
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.