1-bit and 2-bit Characters
2017-11-14 09:33
176 查看
创建一个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
否则 返回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
相关文章推荐
- LeetCode.717 1-bit and 2-bit Characters
- leetcode 717. 1-bit and 2-bit Characters 编码判断问题 + 贪心算法 + 遍历即可
- LeetCode 717. 1-bit and 2-bit Characters
- 717. 1-bit and 2-bit Characters
- Leetcode#717. 1-bit and 2-bit Characters
- 717. 1-bit and 2-bit Characters
- LeetCode717. 1-bit and 2-bit Characters 解题
- 1-bit and 2-bit Characters
- 717. 1-bit and 2-bit Characters
- Array-1-bit and 2-bit Characters
- 717. 1-bit and 2-bit Characters--Python
- [Leetcode] 717. 1-bit and 2-bit Characters 解题报告
- LWC 56:717. 1-bit and 2-bit Characters
- 717 1-bit and 2-bit Characters
- (算法分析Week18)1-bit and 2-bit Characters[Easy]
- 【LeetCode】717. 1-bit and 2-bit Characters(一位数和两位数)
- 1-bit and 2-bit Characters问题及解法
- 717. 1-bit and 2-bit Characters
- LeetCode-717. 1-bit and 2-bit Characters
- 1-bit and 2-bit Characters:判断有1或2位编码构成的编码