Notice
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
- map
- Array
- 코딩 테세트
- 른당사피
- 6월 첼린지
- 코테
- 해물감성포차
- Python
- prefix sum
- two pointers
- 맛집
- algorithm
- 알고리즘
- java
- algorithum
- 발리 음식
- findDulicate
- 투포인터
- tree
- two sum
- 망원 밥집
- LeetCode
- linked list
- 발리인망원
- string
- 코딩 테스트
- invert Binary Tree
- 알탕뚝배기
- 사당돈
- Find the Duplicate Number
Archives
- Today
- Total
기록하는 공간
[코딜리티] PermMissingElem 본문
문제
N의 길이를 가지는 A라는 배열이 있다. A라는 배열에는 1 부터 (N + 1) 까지 수 중에 중복되지 않게 랜덤으로 들어가 있다.
N의 범위는 1~100,000 입니다.
function solution(A) { const arrayLength = A.length; let i = 1; if (arrayLength < 1){ return 1; } if (!A.includes(arrayLength + 1)){ return arrayLength + 1; } A = A.sort((f, s) => { return f-s; }); while (i <= arrayLength){ if (i !== A[i-1]){ return i; } i++; } }
'알고리즘 > Codility' 카테고리의 다른 글
[코딜리티] Flog Jumb (0) | 2019.01.12 |
---|---|
[코딜리티] CyclicRotation (0) | 2019.01.09 |
[코딜리티] BinaryGap(이진 갭 알고리즘) (0) | 2018.12.15 |
[코딜리티] OddOccurrencesInArray (0) | 2018.10.24 |
Comments