์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- Extended Slices
- ์ด๊ฒ์ด ์ทจ์ ์ ์ํ ์ฝ๋ฉํ ์คํธ๋ค
- matplotlib
- ๋ธ๋ผ์ฐ์ ์คํ
- PYTHON
- ์ต์
- MacOS
- ์ฐธ์กฐ ๋ณ์
- ํฉํ ๋ฆฌ์ผ ์ง๋ฒ
- np.zeros_like
- 2BPerfect
- ๋ฐ์ค๊ทธ๋ํ
- ์ง ๊ฐ ์์ธก ๋ถ์
- ์๋ฐ
- DFS
- BFS
- ํ๋ก๊ทธ๋๋จธ์ค
- Do it
- ๋ค์ต์คํธ๋ผ ์๊ณ ๋ฆฌ์ฆ
- jdbc
- ์์ด
- Do_it
- ๋ฐฑ์ค
- java
- sql
- ์ ํ ํฌ ํ์ด์ฌ
- ํ์ ๋ณ์
- dacon
- mysql
- ์ด์ง์ ๋ณํ
- Today
- Total
๋ชฉ๋กDevelopment/CodingTest (34)
๐ฆ ๊ณต๋ฃก์ด ๋์!
๋๋น ์ฐ์ ํ์(BFS) from collections import deque #BFS ๋ฉ์๋ ์ ์ def bfs(graph, start, visited): # ํ(Queue) ๊ตฌํ์ ์ํด deque ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ queue = deque([start]) # ํ์ฌ ๋ ธ๋๋ฅผ ๋ฐฉ๋ฌธ ์ฒ๋ฆฌ visited[start] = True # ํ๊ฐ ๋น ๋๊น์ง ๋ฐ๋ณต while queue: # ํ์์ ํ๋์ ์์๋ฅผ ๋ฝ์ ์ถ๋ ฅํ๊ธฐ v = queue.popleft() print(v, end=' ') # ์์ง ๋ฐฉ๋ฌธํ์ง ์์ ์ธ์ ํ ์์๋ค์ ํ์ ์ฝ์ for i in graph[v]: if not visited[i]: queue.append(i) visited[i] = True # ๊ฐ ๋ ธ๋๊ฐ ์ฐ๊ฒฐ๋ ์ ๋ณด๋ฅผ ํํ (2์ฐจ์ ๋ฆฌ์คํธ) g..

# ex) ๋ฏธ๋ก์ฐพ๊ธฐ ํต์ฌ ์ฝ๋ ๋ฆฌ๋ทฐ while len(stack)>0: now = stack.pop() if now ==dest: return True x= now[1] # ์ด y= now[0] # ํ if x - 1 > -1: if maps[y][x-1]==0: stack.append([x-1,y]) maps[y][x-1]=2 if x + 1 -1: # ์๋ก ์ด๋ํ ์ ์์ผ๋ฉด if maps[y-1][x]==0: stack.append([x,y-1]) maps[y-1][x]=2 if y + 1 < verti: # verti = y ์ขํ ๋ i..
import java.util.*; class Solution { ArrayList answer; boolean[] visited; public int solution(String numbers) { answer = new ArrayList(); visited = new boolean[numbers.length()]; int[] nums = new int[numbers.length()]; for(int i = 0; i < nums.length; i++) { nums[i] = Integer.parseInt(numbers.charAt(i)+""); } for(int i = 1; i

// arr ๋ฝ๊ธฐ๋ฅผ ํ๋ ค๊ณ ๋ชจ์ ๊ฐ๋ค // output ์ถ๋ ฅ ๋๋ ๊ฐ // visited ์ค๋ณต๊ฐ ๋ฐฉ์ง public class Permutation { public static void main(String[] args) { int n = 3; int[] arr = {1, 2, 3}; int[] output = new int[n]; boolean[] visited = new boolean[n]; perm(arr, output, visited, 0, n, 3); // Swap ์์ด // System.out.println(); // permutation(arr, 0, n, 3); } // ์ฌ์ฉ ์์: perm(arr, output, visited, 0, n, 3); static void perm(int[] a..

๋ฐฐ์ด์ ์ฒซ ๊ฐ๋ถํฐ ์์๋๋ก ํ๋์ฉ ๋ฐ๊พธ๋ฉฐ ๋ชจ๋ ๊ฐ์ ํ ๋ฒ์ฉ swap depth๋ฅผ ๊ธฐ์ค ์ธ๋ฑ์ค๋ก ํ์ฌ depth๋ณด๋ค ์ธ๋ฑ์ค๊ฐ ์์ ๊ฐ๋ค์ ๊ทธ๋๋ก ๊ณ ์ ํ๊ณ depth๋ณด๋ค ์ธ๋ฑ์ค๊ฐ ํฐ ๊ฐ๋ค๋ง ๊ฐ์ง๊ณ ๋ค์ swap ์์๊ฐ ๋ณด์ฅ๋์ง ์์ ๋ง์ง๋ง 321,312 ๋ถ๋ถ public class Permutation { public static void main(String[] args) { int n = 3; int[] arr = {1, 2, 3}; int[] output = new int[n]; //boolean[] visited = new boolean[n]; // visited๋ฅผ ์ด์ฉํ ์์ด์์ ์ค๋ช ์์ // perm(arr, output, visited, 0, n, 3); // System.out.println..

1. import java.util.Scanner; public class Test { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); String ns = sc.nextLine(); int m = sc.nextInt(); sc.nextLine(); String ms = sc.nextLine(); String[] na = ns.split(" "); String[] ma = ms.split(" "); int[] answer = new int[m]; for (int i = 0; i < m; i++) { for (int ..