1-bit and 2-bit Characters

来源:互联网 发布:英语教练淘宝没了 编辑:程序博客网 时间:2024/05/16 06:59
创建一个index 来跟踪判断是否index 会 跳到 n-1 ,如果可以的话  则返回True
否则 返回False。
    if not bits: return False
    n = len(bits)
   
    index = 0
    while index < n:
        if index == n-1 : return True
        if bits[index] == 1:
            index += 2             
        else: index += 1
    return False
原创粉丝点击