Last active
October 1, 2017 06:03
-
-
Save johndavedecano/88d6c1b8cbed623bfbc8d8f0cfbff029 to your computer and use it in GitHub Desktop.
EXAMS - Binary Gap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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