Skip to content

Instantly share code, notes, and snippets.

@cassianorabelo
Last active January 25, 2016 23:32
Show Gist options
  • Save cassianorabelo/566310656964d71ab1ef to your computer and use it in GitHub Desktop.
Save cassianorabelo/566310656964d71ab1ef to your computer and use it in GitHub Desktop.
function solution(N) {
var i = false;
var big_gap = 0;
var count = 0;
while (N > 0) {
if (N%2) {
i = true;
if (count > big_gap) big_gap = count;
count = 0;
} else {
if (i) count++;
}
N = N >> 1;
}
return big_gap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment