Java/JavaScript Two Lines. No Regex


  • 0
    J

    Very simple. Pass all tests.

    Java

    public boolean checkRecord(String s) {
            if (s.contains("LLL") || s.indexOf("A") != s.lastIndexOf("A")) return false;
            else return true; 
        }
    

    JavaScript

    var checkRecord = function(s) {
        if(s.includes("LLL") || s.indexOf("A") != s.lastIndexOf("A")) return false;
        else return true;
    };
    

Log in to reply
 

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