하다보면 되겠지 5

[codility] 풀어보기 - MaxCounters

Lesson 4-4 - MaxCounters내용 : Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.문제 설명은 여기를 참고 http://hojak99.tistory.com/316 시간 복잡도 : O(N+M)80% 코드 :function solution(N, A) { // write your code in JavaScript (Node.js 6.4.0) let rt_arr = new Array(N); let max_counter = 0; let now_idx=0; rt_arr.fill(0); for..

알고리즘 2017.10.18

[codility] 풀어보기 - PermMissingElem

Lesson 3-2 - PermMissingElem내용 :Find the missing element in a given permutation시간 복잡도 : O(N) 성공 했지만 민망해서 공개 안하는 코드 : function isZero(element) { return element == 1; } function solution(A) { // write your code in JavaScript (Node.js 6.4.0) let rt_arr=new Array(A.length+1); rt_arr.fill(1); for(i in A) { rt_arr[A[i]-1]=0; } //console.log(rt_arr.findIndex(isZero)+1); return rt_arr.findIndex(isZero)+..

알고리즘 2017.09.26