Java solution


  • 1
    L
        public boolean checkRecord(String s) {
        int acount=0;
        int lcount=0;
        for(char c : s.toCharArray()) {
            if(c=='L') {
                lcount++;
            }
            else {
                lcount=0;
                if(c=='A') {
                    acount++;
                }
            }
            if(acount>1 || lcount>=3) {
                return false;
            }
        }
        return true;
       }
    

Log in to reply
 

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