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 比特字符
最新推荐文章于 2025-12-02 18:04:47 发布
该篇博客主要介绍了一个Java解决方案,用于判断给定的二进制数组是否表示一个一比特字符。代码中包含一个主方法和一个核心判断函数,通过正序遍历确保结尾为0,从而确定字符类型。

563

被折叠的 条评论
为什么被折叠?



