You are viewing a single comment's thread. Return to all comments →
in java style
public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String k = Integer.toBinaryString(n); char[] binary = k.toCharArray(); int count=0,max=0; for(int i=0;i<binary.length;i++){ if(binary[i]=='1') count++; if(count>max) max = count; if(binary[i]=='0') count = 0; } System.out.println(max); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →
in java style