32 ms solution - Simple Python Solution


  • 0
    D
    class Solution(object):
        def isOneBitCharacter(self, bits):
            """
            :type bits: List[int]
            :rtype: bool
            """
            if bits[-1] != 0:
                return False
            bits = bits[:len(bits)-1]
            index = 0
            while index < len(bits):
                if bits[index] == 0:
                    index += 1
                elif bits[index] == 1:
                    index += 2
            return index == len(bits)
            
    

Log in to reply
 

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