package com.算法专练.力扣.一比特与2比特字符;
/**
* @author xnl
* @Description:
* @date: 2022/8/24 22:24
*/
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
}
/**
* 正序遍历,注意,包证结尾是0 。 所以说,只需要最后遍历的结果长度和开始长度是一致的就行
*
* @param bits
* @return
*/
public boolean isOneBitCharacter(int[] bits) {
int n = bits.length;
int i = 0;
while (i < n - 1){
i += bits[i] + 1;
}
return i == n - 1;
}
}
力扣:717. 1 比特与 2 比特字符
最新推荐文章于 2024-07-25 19:34:38 发布