Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Codility
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