본문 바로가기

Programmers/Level3

(44)
[카카오 인턴] 경주로 건설 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 import java.util.*; class Solution { private static int min = Integer.MAX_VALUE/ 2; private static int[][] direction = { { 1, 0 }, { 0, 1 }, { 0, -1 }, { -1, 0 } }; // 하, 우, 좌, 상 public static void Search(int[][] board, int[][] check, int pre_i, int pre_j, ..
섬 연결하기 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 import java.util.*; class Solution { private static int[] parent; // 부모 설정 public static void Union(int a, int b){ a = Find(a); b = Find(b); if (a > b) { parent[a] = b; } else { parent[b] = a; } } // 부모 찾기 public static int Find(int x) { if (parent[x] == x)..
멀리 뛰기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 class Solution { public long solution(int n) { long answer = 0; int[] arr = new int[n+1]; int div = 1234567; if(n
거스름돈 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import java.util.*; class Solution { public int solution(int n, int[] money) { int answer = 0; int[] arr = new int[n+1]; Arrays.sort(money); arr[0] = 1; for(int m : money){ for(int i=m;i
풍선 터트리기 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 import java.util.*; class Solution { public static int checkBalloon(int[] a){ if(a.length minRight){ if(flag) left++; else right--; } else{ if(flag){ if(n
[1차] 추석 트래픽 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 import java.util.*; class Solution { public static double timeToDouble(String time) { String[] arr = time.split(":"); return Double.parseDouble(arr[0]) * 60 * 60 + Double.parseDouble(arr[1]) * 60 + Double.parseDouble(arr[2]); } public int solution(..
길 찾기 게임 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 import java.util.*; class Solution { public static void Connect(Node parent, Node child) { if (parent.x > child.x) { if (parent.left == null) { parent.left = child; } else { Conne..
자물쇠와 열쇠 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 class Solution { private static int n, m, zeroCnt = 0; public static int[][] Rotate(int[][] key) { int n = key.length; // 상하 반전 for (int i = 0; i