You are viewing a single comment's thread. Return to all comments →
I would say, if you're going to that, just do:
public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] ones = Integer.toBinaryString(n).split("[0]+"); int max = 0; for (String s : ones) { if (s.length() > max) max = s.length(); } 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 →
I would say, if you're going to that, just do: