Skip to content

Instantly share code, notes, and snippets.

@johndavedecano
Last active October 1, 2017 06:03
Show Gist options
  • Save johndavedecano/88d6c1b8cbed623bfbc8d8f0cfbff029 to your computer and use it in GitHub Desktop.
Save johndavedecano/88d6c1b8cbed623bfbc8d8f0cfbff029 to your computer and use it in GitHub Desktop.
EXAMS - Binary Gap
function solution(A) {
const rep = (A >>> 0)
.toString(2)
.split(1)
.filter(x => x !== "")
.sort(function(a, b) {
return b.length - a.length;
});
return rep.length === 0 ? 0 : rep[0].length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment