본문 바로가기

Programmers

(188)
정수 삼각형 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution { public int solution(int[][] triangle) { int answer = 0; int row = triangle.length; for (int i = 1; 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 import java.util.*; class Solution { private static int min; public static void DFS(ArrayList wordList, String str, String target, int n, int cnt) { // 변환 최솟값 저장 if (str.equals(target)) { if (min > cnt) min = cnt; return; } 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 import java.util.*; class Solution { public long solution(int n, int[] times) { long answer = 0; Arrays.sort(times); long left = 0; long right = (long) n * times[times.length - 1]; // 최대로 걸리는 시간 while (left
가장 먼 노드 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 78 import java.util.*; class Solution { private static ArrayList listGraph = new ArrayList(); private static int MAX_VALUE = 20001; private static int maxDistance = -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 54 class Solution { public int[] solution(int rows, int columns, int[][] queries) { int[][] matrix = new int[rows][columns]; int[] answer = new int[queries.length]; int i, j, cnt = 1; // 행렬 초기화 for (i = 0; i x1 + 1; j--) { matrix[j][y2] = matrix[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 51 52 53 class Solution { private static int[] addRow = { 1, -1, 0, 0, 2, -2, 0, 0, 1, 1, -1, -1 }; private static int[] addCol = { 0, 0, -1, 1, 0, 0, -2, 2, -1, 1, -1, 1 }; public static int placeCheck(String[] place) { char[][] cArr = new char[place.lengt..
배달 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 class Solution { private static int maps[][]; private static int MAX_VALUE = 500001; public static void Input(int i, int j, int w) { if (maps[i][j] > w) { maps[i][j] = w; maps[j][i] ..
adenCase 문자열 만들기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class Solution { public String solution(String s) { String answer = ""; StringBuilder sb = new StringBuilder(); boolean firstFlag = true; s = s.toLowerCase(); for (int i = 0; i