File tree 3 files changed +27
-4
lines changed
3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 1
1
# LeetCode Algorithms
2
2
3
- ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-175 /2081-1f425f.svg )
4
- ![ problems-solved-java] ( https://img.shields.io/badge/Java-175 /2081-1abc9c.svg )
5
- ![ problems-solved-python] ( https://img.shields.io/badge/Python-175 /2081-1abc9c.svg )
3
+ ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-176 /2081-1f425f.svg )
4
+ ![ problems-solved-java] ( https://img.shields.io/badge/Java-176 /2081-1abc9c.svg )
5
+ ![ problems-solved-python] ( https://img.shields.io/badge/Python-176 /2081-1abc9c.svg )
6
6
[ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( CONTRIBUTING.md )
7
7
[ ![ cp] ( https://img.shields.io/badge/also%20see-Competitve%20Programming-1f72ff.svg )] ( https://github.com/anishLearnsToCode/competitive-programming )
8
8
197
197
| 706 | [ Design HashMap] ( https://leetcode.com/problems/design-hashmap ) | [ ![ Java] ( assets/java.png )] ( src/DesignHashMap.java ) [ ![ Python] ( assets/python.png )] ( python/design_hash_map.py ) |
198
198
| 709 | [ To Lower Case] ( https://leetcode.com/problems/to-lower-case ) | [ ![ Java] ( assets/java.png )] ( src/ToLowerCase.java ) [ ![ Python] ( assets/python.png )] ( python/to_lower_case.py ) |
199
199
| 716 | [ Max Stack] ( https://leetcode.com/problems/max-stack ) | |
200
- | 717 | [ 1-bit and 2-bit Characters] ( https://leetcode.com/problems/1-bit-and-2-bit-characters ) | |
200
+ | 717 | [ 1-bit and 2-bit Characters] ( https://leetcode.com/problems/1-bit-and-2-bit-characters ) | [ ![ Java ] ( assets/java.png )] ( src/OneBitAndTwoBitCharacters.java ) [ ![ Python ] ( assets/python.png )] ( python/one_bit_and_two_bit_characters.py ) |
201
201
| 720 | [ Longest Word in Dictionary] ( https://leetcode.com/problems/longest-word-in-dictionary ) | |
202
202
| 724 | [ Find Pivot Index] ( https://leetcode.com/problems/find-pivot-index ) | |
203
203
| 728 | [ Self Dividing Numbers] ( https://leetcode.com/problems/self-dividing-numbers ) | |
Original file line number Diff line number Diff line change
1
+ from typing import List
2
+
3
+
4
+ class Solution :
5
+ def isOneBitCharacter (self , bits : List [int ]) -> bool :
6
+ count = 0
7
+ index = len (bits ) - 2
8
+ while index >= 0 and bits [index ] != 0 :
9
+ if bits [index ] == 1 : count += 1
10
+ index -= 1
11
+ return count % 2 == 0
Original file line number Diff line number Diff line change
1
+ public class OneBitAndTwoBitCharacters {
2
+ public boolean isOneBitCharacter (int [] bits ) {
3
+ for (int index = 0 ; index < bits .length ; index ++) {
4
+ if (bits [index ] == 1 ) {
5
+ index ++;
6
+ } else if (bits [index ] == 0 && index == bits .length - 1 ) {
7
+ return true ;
8
+ }
9
+ }
10
+ return false ;
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments