IT General
Codility #1-BinaryGap
SoftArts
2018. 8. 15. 15:42
function solution(N) {
let trimmed = (N).toString(2).replace(/0+$/, ''); // Binary string right trimmed with '0' characters.
let gaps = trimmed.split('1').map((item) => item.length);
return Math.max(...gaps);
}