-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary number
More file actions
50 lines (38 loc) · 1.27 KB
/
binary number
File metadata and controls
50 lines (38 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int number = scan.nextInt();
int tempCount = 0;
int maxCount = 0;
String s = new String();
s = "";
while(number > 0){
s = s + (number % 2);
number = number >> 1;
}
String[] obj = s.split("0");
Arrays.sort(obj);
System.out.print(obj[obj.length - 1].length());
/* while(!stack.isEmpty()) {
if(stack.pop() == 1){
tempCount++;
maxCount = tempCount;
while(stack.pop() == 1) {
tempCount++;
maxCount = tempCount;
}
tempCount = 0;
}
else
continue;
}
int answer = (tempCount > maxCount) ? tempCount : maxCount;
// Integer n = 439;
//System.out.println(Integer.toBinaryString(n))
*/
//System.out.print(answer);
}
}