본문 바로가기

Programmers/Level2

(76)
행렬 테두리 회전하기 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
순위 검색 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 import java.util.*; class Solution { private static Map allInfo = new HashMap(); private static ArrayList score = new ArrayList(); public static void DFS(String pos, int depth, String[] info) { if (depth == 4) { if ..
[3차] 압축 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 import java.util.*; class Solution { public int[] solution(String msg) { int[] answer = {}; Map map = new HashMap(); List list = new ArrayList(); int i = 1, j = 0; char c = 'A'; // 알파벳 초기화 while (c
2개 이하로 다른 비트 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 long[] solution(long[] numbers) { long[] answer = new long[numbers.length]; for (int i = 0; i
행렬의 곱셈 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int[][] answer = new int[arr1.length][arr2[0].length]; for (int i = 0; i