Created
April 17, 2016 16:39
-
-
Save tomaskikutis/70c66a7c6752051b619d99568545b128 to your computer and use it in GitHub Desktop.
Codility
This file contains 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
var trim = require("lodash/trim"); | |
var max = require("lodash/max"); | |
var dec2bin = function (dec){ | |
return (dec >>> 0).toString(2); | |
}; | |
var getLargestBinaryGap = function(n){ | |
return max( | |
trim(dec2bin(n), "0") | |
.split("1") | |
.map(function(a){ | |
return a.length; | |
}) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment