We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent efb49e8 commit 984d853Copy full SHA for 984d853
BIT/868.md
@@ -0,0 +1,30 @@
1
+## Binary Gap
2
+
3
+#### Description
4
5
+[link](https://leetcode.com/problems/binary-gap/)
6
7
+---
8
9
+#### Solution
10
11
+- bin in python
12
13
14
15
+#### Code
16
17
+O(n)
18
19
+```python
20
+class Solution:
21
+ def binaryGap(self, N: int) -> int:
22
+ s = bin(N)
23
+ res = 0
24
+ i = float('inf')
25
+ for j, n in enumerate(s[2:]):
26
+ if n == '1':
27
+ res = max(res, j - i)
28
+ i = j
29
+ return res
30
+```
0 commit comments