전체 글

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182import java.util.*; class Solution { private static List nodeList; private static boolean[][] visited; public int solution(int n, int[][] wires) { int answer = Integer.MAX_VALUE; nodeList = new ArrayList(); for(int i=0; i
실패원인 int형을 long값으로 바꾸어야함 maxX , minX, maxY, minY를 Long.MAX_VALUE, Long.MIN_VALUE로 초기화해야함 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import java.util.HashSet;import java.util.Arrays;class Solution { static long minx= Long.MAX_VALUE, miny= Long.MAX_VALUE; static long maxx= Long.MIN_VALUE, maxy= Long.MIN_VAL..
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 import java.util.*; class Solution { public int solution(int[] people, int limit) { Arrays.sort(people); // System.out.println(people[0]); int answer = 0; int i = 0; int j = people.length-1; while(i
2중 for문 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Solution { public int[] solution(int[] prices) { int[] answer = new int[prices.length]; int len = prices.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 import java.util.*; class Solution { public int[] solution(int n, String[] words) { int[] answer = {0, 0}; Set map = new HashSet(); map.add(words[0]); for(int i=1; i
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import java.util.*; class Solution { private static int[] dr = {1, 0, -1}; private static int[] dc = {0, 1, -1}; public int[] solution(int n) { int[][] temp = new int[n][n]; int r = -1; int c = 0; int i = 0; int currVal = 1; boolean dirChanged = true; while(true){ int nr = r+dr[i]; int ..
(틀린 코드) 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 class Solution { public long[] solution(long[] numbers) { long[] answer = new long[numbers.length]; for(int i=0; i0 && diffBitNum 11 (뒤에 자릿수가 없기 때문에 이거는 비트를 1개만 바꾸는 것이 최소값임) 그리고 0이 없는 경우인 11111111.........11111111로만 가득찬 경우 가장 앞자리를 0으로 바꾼 후에 다시 가장 앞자리에 1을 붙여주면됨 11111111.........11111111(n자리수) -> 101111111.........1111111..
좌표 설정 (nx = x+dx[k])를 잘못해서 ( (ny = x+dy[k])이런 식으로 실수함 ) 자꾸 IndexOutOfRangeException나고 잘못나옴.. 그냥 빠르게 하는 것보다 확실하게 하면서 속도 늘려야함.. 정확성 100%를 유지하면서 속도를 늘려야함 그게 아니면 속도 의미 없음 그냥 사고나기 딱 좋음 IndexOutOfRangeException이 너무 나옴.. shiftBoard에서도 빠다리 너무남 엄청헤맷다.. 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 5..
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 class Solution { private static int answer; private static boolean[] visited; public int solution(int k, int[][] dungeons) { answer = 0; visited = new boolean[dungeons.length]; DFS(dungeons, k, 0); return answer; } private void DFS(int[][] dungeons, int k, int depth){ // 돌 수 있는 던젼이 하나도 없는 경우 answer = Math.max(ans..
배게
백엔드