Python solution with one or two steps


  • 0
    W

    If start with 0 jump one step else 1 jump two steps until the loop finishes

    class Solution(object):
        def isOneBitCharacter(self, bits):
            """
            :type bits: List[int]
            :rtype: bool
            """
            flag = None
            i = 0
            while i < len(bits):
                if bits[i] == 0:
                    flag = True
                    i += 1
                else:
                    if i < len(bits):
                        flag = False
                        i += 2
            return flag
    

Log in to reply
 

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