You are viewing a single comment's thread. Return to all comments →
int n = in.nextInt();
long m = n; int maxCount = 0; int count = 0; long prev = -1; while(m != 0) { long current = m & 1; if(current == 1 && current == prev) { count++; }else { count = 1; } if(count > maxCount){ maxCount = count; } prev = current; m = m >> 1; } System.out.println(maxCount); in.close();
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 →
int n = in.nextInt();