1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| // @Title: 1 比特与 2 比特字符 (1-bit and 2-bit Characters)
// @Author: 15816537946@163.com
// @Date: 2022-02-20 18:35:54
// @Runtime: 0 ms
// @Memory: 2.6 MB
func isOneBitCharacter(bits []int) bool {
n,idx := len(bits),0
for idx < n-1 {
if bits[idx] == 0 {
idx++
} else {
idx+=2
}
}
return idx == n-1
}
|