Skip to content

Commit

Permalink
Create binary number
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajwadhwa authored Oct 20, 2016
1 parent 1f7612e commit fb9a0ac
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions binary number
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);

}
}

0 comments on commit fb9a0ac

Please sign in to comment.