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 |
Tags
- 매일메일
- SW
- createSlice
- redux-saga
- react
- 리액트
- 알고리즘
- programmers
- useDispatch
- Algorithm
- 항해99
- react-redux
- sw expert academy
- maeil-mail
- Python
- react-router
- JavaScript
- 자바
- 항해플러스
- 프로그래머스
- java
- json-server
- redux
- 코딩테스트합격자되기
- Get
- C++
- redux-toolkit
- 테코테코
- axios
- 이코테
Archives
- Today
- Total
목록재귀함수 (2)
Binary Journey
[프로그래머스] 프로그래머스 124 나라의 숫자
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 3진법이라는 알았는데 for문으로 접근했다가 시간을 너무 오래 잡아먹었다. 결국 구글링해서 답을 알아냈는데 생각보다 더 간단했다. while 을 사용하면 이렇고 function solution(n) { const availableNumber = [ 4, 1, 2 ]; let answer = ''; while (n) { answer = availableNumber[n % 3] + answer; n = n % 3 ? Math.floor(n / 3) : n / 3 - 1; } return answer; } 더 줄이면 이렇게 된다. 추천 가장 많이 받은 식인데 재귀함수 방..
프로그래머스/level 2
2021. 4. 22. 21:52