Python: Beats 94.5% solutions


  • 0
    5
    def checkRecord(self, s):
        """
        :type s: str
        :rtype: bool
        """
        cntA=0
        for ix, i in enumerate(s):
            if i =="A":
                cntA+=1
            if cntA>1:
                return False
            if i == "L" and ix>=2 and s[ix]==s[ix-1]==s[ix-2]:
                return False
        return True
    

Log in to reply
 

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