File tree 3 files changed +33
-0
lines changed
3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
### 📖 [ NOTES 바로가기] ( ./notes )
8
8
9
+ ## Iterations
10
+
11
+ | # | ☆ | Problem | Note |
12
+ | :-: | :-: | :----------------------------------------------- | :--- |
13
+ | 01 | | [ Codility-Lesson1 BinaryGap] ( ./src/Iterations/BinaryGap ) | |
14
+
9
15
## DFS & BFS
10
16
11
17
| # | ☆ | Problem | Note |
Original file line number Diff line number Diff line change
1
+ package Iterations .BinaryGap ;
2
+
3
+ public class Main {
4
+
5
+ public static void main (String [] args ) {
6
+ Solution s = new Solution ();
7
+ System .out .println (s .solution (1041 ));
8
+ System .out .println (s .solution (8 ));
9
+ }
10
+ }
11
+
12
+ class Solution {
13
+ public int solution (int N ) {
14
+ char [] binArr = Integer .toBinaryString (N ).toCharArray ();
15
+ int ans = 0 , start = 0 ;
16
+ for (int i = 1 ; i < binArr .length ; i ++) {
17
+ if (binArr [i ] == '1' ) {
18
+ ans = Math .max (ans , i - start - 1 );
19
+ start = i ;
20
+ }
21
+ }
22
+ return ans ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ ## [ Codility - Lesson 1 Iterations] BinaryGap
2
+
3
+ ![ image] ( https://user-images.githubusercontent.com/22045163/101761832-f972b000-3b1f-11eb-80fd-7c05c6a919e2.png )
You can’t perform that action at this time.
0 commit comments