旅游玩耍休息了一个假期!回来惹!排名掉的哭惹!好好学习 哭哭~
java:
class Solution {
public boolean isOneBitCharacter(int[] bits) {
int n = bits.length;
int m = n -1;
int pos = 0;
while (pos < m){
if (bits[pos] == 0) {
pos ++;
} else {
pos += 2;
}
}
return pos == m;
}
}
python:
class Solution:
def isOneBitCharacter(self, bits: List[int]) -> bool:
n = len(bits)
m = n - 1
pos = 0
while pos < m:
if bits[pos] == 0:
pos += 1
else:
pos += 2
return pos == m