Skip to content

Instantly share code, notes, and snippets.

@kanelv
Created March 8, 2023 13:12
Show Gist options
  • Save kanelv/1e4ca83140c24c25d36d63d9ad09ca19 to your computer and use it in GitHub Desktop.
Save kanelv/1e4ca83140c24c25d36d63d9ad09ca19 to your computer and use it in GitHub Desktop.
BinaryGap
const solution = (N) => {
const binary = N.toString(2);
let count = 0;
let answer = 0;
for(let b of binary) {
if (b === "0") {
count++
} else {
if (count > answer) {
answer = count;
}
count = 0
}
}
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment