Skip to content

Commit 9e962f6

Browse files
committedFeb 12, 2025
Add solution #717
1 parent 5acf477 commit 9e962f6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@
324324
705|[Design HashSet](./0705-design-hashset.js)|Easy|
325325
706|[Design HashMap](./0706-design-hashmap.js)|Easy|
326326
713|[Subarray Product Less Than K](./0713-subarray-product-less-than-k.js)|Medium|
327+
717|[1-bit and 2-bit Characters](./0717-1-bit-and-2-bit-characters.js)|Easy|
327328
720|[Longest Word in Dictionary](./0720-longest-word-in-dictionary.js)|Medium|
328329
722|[Remove Comments](./0722-remove-comments.js)|Medium|
329330
724|[Find Pivot Index](./0724-find-pivot-index.js)|Easy|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* 717. 1-bit and 2-bit Characters
3+
* https://leetcode.com/problems/1-bit-and-2-bit-characters/
4+
* Difficulty: Easy
5+
*
6+
* We have two special characters:
7+
* - The first character can be represented by one bit 0.
8+
* - The second character can be represented by two bits (10 or 11).
9+
*
10+
* Given a binary array bits that ends with 0, return true if the last character
11+
* must be a one-bit character.
12+
*/
13+
14+
/**
15+
* @param {number[]} bits
16+
* @return {boolean}
17+
*/
18+
var isOneBitCharacter = function(bits) {
19+
return bits.slice(0, bits.length - 1).join('').replace(/11|10|0/g, '') !== '1';
20+
};

0 commit comments

Comments
 (0)
Please sign in to comment.