Python O(n) easy understanding solution beat 98%


  • 0
    A
    class Solution(object):
        def checkRecord(self, s):
            """
            :type s: str
            :rtype: bool
            """
            if s.count('A') > 1:
                return False
            s = list(s)
            for i in range(1,len(s)-1):
                if s[i] == 'L' and s[i] == s[i-1] ==s[i+1]:
                    return False
            return True

Log in to reply
 

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