반응형
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- 알고리즘
- MaterialUI
- next
- js
- solution
- HTML
- Javasript
- eslint
- 상호 평가
- From
- level1
- array
- Prettier
- 폼
- Collapse
- Weekly Challenge
- javscript
- Weekly
- algorithm
- javascript
- programmers
- form
- component
- nextjs
- React
- 리액트
- Challenge
- redux-toolkit
- 직업군 추천하기
- split
Archives
- Today
- Total
목록Algorithm/Codility (1)
기록

문제 부터 2,147,483,647 사이의 숫자들 중에서 하나가 주어지면 그 숫자를 2진수로 변환했을때 1과 1 사이의 연속적인 0의 길이가 긴 길이를 리턴 풀이 function solution(N) { const binary = N.toString(2); const binaryGaps = binary.slice(binary.indexOf('1') + 1, binary.lastIndexOf('1')); if (!binaryGaps) { return 0; } const zeroArray = binaryGaps.split('1').map(zeros => zeros.length); return Math.max(...zeroArray) } binary -> 2진수binaryGaps -> 첫위치 1과 마지막 1 ..
Algorithm/Codility
2021. 6. 3. 11:49