-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f7612e
commit fb9a0ac
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
|
||
} | ||
} |