You are viewing a single comment's thread. Return to all comments →
Hello this is the smallest and easiest code in java:::: public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int consec1=0; String strBinary = Integer.toString(n, 2); // System.out.println("Binary equivalent: "+Integer.toString(n, 2)); String[] strparts = strBinary.split("0"); for(int i=0;i<strparts.length;i++ ){ if (consec1 < strparts[i].length()) {consec1 = strparts[i].length();} } System.out.println(consec1); }
}
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 →
Hello this is the smallest and easiest code in java:::: public class Solution {
}