• 문제 링크
1-bit and 2-bit Characters - LeetCode
Can you solve this real interview question? 1-bit and 2-bit Characters - We have two special characters: * The first character can be represented by one bit 0. * The second character can be represented by two bits (10 or 11). Given a binary array bits that
leetcode.com
• 풀이 코드
public class Solution {
public boolean isOneBitCharacter(int[] bits) {
int i = 0, n = bits.length - 1;
while (i < n) i += bits[i] == 0 ? 1 : 2;
return i == n;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 728. Self Dividing Numbers - Java (0) | 2026.10.05 |
|---|---|
| [LeetCode] 724. Find Pivot Index - Java (0) | 2026.10.04 |
| [LeetCode] 709. To Lower Case - Java (0) | 2026.10.02 |
| [LeetCode] 706. Design HashMap - Java (0) | 2026.10.01 |
| [LeetCode] 705. Design HashSet - Java (0) | 2026.09.30 |
댓글