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);
}


'IT General' 카테고리의 다른 글

Codility #3-PermMissingElem  (0) 2018.08.18
Codility #3-FrogJmp  (0) 2018.08.18
Codility #2-OddOccurrencesInArray  (0) 2018.08.18
Codility #2-CyclicRotation  (0) 2018.08.18
Fibonacci function without recursion  (0) 2018.08.15

+ Recent posts