Skip to content

Commit 6c02567

Browse files
authored
Create 717. 1-bit and 2-bit Characters (#936)
2 parents b1a779e + 8133625 commit 6c02567

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

717. 1-bit and 2-bit Characters

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public:
3+
bool isOneBitCharacter(vector<int>& bits) {
4+
int n = bits.size();
5+
int i = 0;
6+
7+
while(i < n - 1) {
8+
if(bits[i] == 1) {
9+
i += 2;
10+
} else {
11+
i += 1;
12+
}
13+
}
14+
return i == n - 1;
15+
}
16+
};

0 commit comments

Comments
 (0)