본문 바로가기

-

(212)
거스름돈 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
2차원 배열 회전 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 public static int[][] Rotate(int[][] key) { int n = key.length; // 상하 반전 for (int i = 0; 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 import java.util.*; class Solution { public static boolean sectionCheck(int[] stones, int k, int mid) { int cnt = 0; for (int i = 0; i
N으로 표현 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 class Solution { private static int min = 9; public static void DFS(int num, int N, int cnt, int res) { // 최솟값 갱신 if (num == res) { min = Math.min(cnt, min); return; } int add = N; // cnt가 8을 넘지 않을 경우만 수행 for (int i = 0; i