일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 자바스크립트
- Python
- 타입스크립트
- softeer
- 프로그래머스
- 문자열
- 스택
- 소프티어
- SQL 고득점 KIT
- 파이썬
- DP
- Typescript
- level3
- 너비 우선 탐색
- Stack
- 브루트포스
- group by
- Dynamic Programming
- Lv. 3
- Lv. 1
- programmers
- Lv. 2
- bfs
- 다이나믹프로그래밍
- Lv. 0
- javascript
- level 3
- C언어
- Java
- dfs
- Today
- Total
목록알고리즘/알고리즘 이론 (6)
몸과 마음이 건전한 SW 개발자
문제 링크https://school.programmers.co.kr/learn/courses/30/lessons/12940 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr정답 코드class Solution { public int gcd(int n, int m) { // m이 크다고 전제하고 게산 int tmp = m; if (n > m) { m = n; n = tmp; } while (n > 0) { int o = m; ..
구현 1 : 쉬프트 연산자(>>) 사용하기function toBinaryUsingShift(num) { let binary = ""; while (num > 0) { let lastBit = num & 1; // num의 마지막 비트를 가져옵니다. binary = lastBit + binary; // 결과 문자열에 비트를 추가합니다. num = num >> 1; // 오른쪽으로 한 비트 쉬프트합니다. } return binary || "0";}구현 2 : 숫자를 2로 나누기function toBinaryUsingDivision(num) { let binary = ""; while (num > 0) { let remai..
구현 // 최대공약수 const gcd = (n1, n2) => { // 일반적으로 n1이 크다고 전제하고 계산 if (n2 > n1) { [n1, n2] = [n2, n1]; }; // n2가 0이 될 때까지 진행 while (n2) { [n1, n2] = [n2, n1%n2]; }; return n1 }; // 단순 최소공배수 const simpleLcm = (n1, n2) => { for (let num = Math.max(n1, n2); num { // 최대공약수를 활용 return (n1 * n2) / gcd(n1, n2); }; console.log(uclidLcm(123, 456)); // 18696 console.log(simpleLcm(123, 456)); // 18696
구현 const eratostenes = (number) => { if (number
구현 def bubbleSortAsc(arr, n): for idx in range(n-1, -1, -1): for jdx in range(idx): if arr[jdx] > arr[jdx+1]: arr[jdx], arr[jdx+1] = arr[jdx+1], arr[jdx] return arr def bubbleSortDesc(arr, n): for idx in range(n-1, -1, -1): for jdx in range(idx): if arr[jdx] < arr[jdx+1]: arr[jdx], arr[jdx+1] = arr[jdx+1], arr[jdx] return arr arr = [2, 7, 5, 1, 4, 6, 3] sortedArrAsc = bubbleSortAsc(arr, len(arr)..
순열 만드는 방법 1. 방문 배열을 안에 N = 5 def dfs(S, N, V, chosen): if S == N: print(chosen) return for i in range(N): if i not in V: dfs(S+1, N, V+[i], chosen + [i]) 2. 방문 배열을 밖에 N = 5 V = [0 for _ in range(N)] def dfs2(S, chosen): if S == N: print(chosen) return for i in range(N): if V[i]: continue V[i] = 1 dfs2(S+1, chosen+[i]) V[i] = 0 dfs2(0, []) 조합 만드는 방법 L = 5 def dfs(S, wishL, nowL, chosen): if S >= ..