일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- MYSQL
- 백준알고리즘
- 안드로이드
- 정렬 알고리즘
- 월간 코드 챌린지 시즌1
- 경력 개발자
- 이직 준비
- 카페
- 입원
- 프로그래머스
- 수술
- 방사성 동위원소 치료
- 폐CT
- 임파선전이
- 전이
- 림프절전이
- 저요오드식
- firebase
- java
- 맛집
- 입원준비
- leetcode
- 갑상선암용인세브란스
- Android
- 갑상선암
- 알고리즘
- 용인세브란스병원
- 객체
- 동위원소치료
- 방사성동위원소치료
Archives
- Today
- Total
새우버거의 개발 블로그
[Java] LeetCode 717 : 1-bit and 2-bit Characters 본문
LeetCode # 717
Example 1:
Input:
bits = [1, 0, 0]
Output: True
Explanation: The only way to decode it is two-bit character and one-bit character. So the last character is one-bit character.
Example 2:
Input:
bits = [1, 1, 1, 0]
Output: False
Explanation: The only way to decode it is two-bit character and one-bit character. So the last character is one-bit character.
Note:
- 1 <= len(bits) <= 1000.
- bits[i] is always 0 or 1.
Solution #1 (0ms)
class Solution {
public boolean isOneBitCharacter(int[] bits) {
int i = 0;
while (i < bits.length - 1) {
i += bits[i] == 1 ? 2 : 1;
}
return i == bits.length - 1;
}
}
Result #1
More Algorithm!
👇👇
github.com/ggujangi/ggu.leet-code
ggujangi/ggu.leet-code
LeetCode, Java. Contribute to ggujangi/ggu.leet-code development by creating an account on GitHub.
github.com
출처 : leetCode
'알고리즘 > LeetCode' 카테고리의 다른 글
[Java] LeetCode 258 : Add Digits (0) | 2021.05.12 |
---|---|
[Java] LeetCode 67 : Add Binary (0) | 2021.05.12 |
[Java] LeetCode 953 : Verifying an Alien Dictionary (0) | 2021.04.21 |
[Java] LeetCode 874 : Walking Robot Simulation (0) | 2021.04.17 |
[Java] LeetCode 1518 : Water Bottles (0) | 2021.04.17 |