프로그래머스2 [프로그래머스] 테이블 해시 함수 Java 풀이 목차 LIST 최종 결과 import java.util.*; public class Main { public static void main(String[] args) { int[][] data = {{2,2,6}, {1,5,10}, {4,2,9}, {3,8,3}}; int res = solution(data, 2, 2, 3); System.out.print(res); } public static int solution(int[][] data, int col, int row_begin, int row_end) { Arrays.sort(data, (o1, o2) ->{ if(o1[col-1] == o2[col-1]) { return Integer.compare(o2[0], o1[0]); } return In.. 2023. 7. 30. [프로그래머스] 숫자 변환하기 Java 풀이 첫 번째 풀이 exists를 사용하지 않으면 시간초과가 뜬다. 이전에 한번이라도 큐에 들어갔던 숫자면 skip. Node 를 쓰고싶지 않았는데, 다른 방법이 생각나지 않아서 사용했다. 밑에 풀이에선 배열로 수정됨 import java.util.*; public class Main { public static void main(String[] args) { int res = solution(2, 5, 4); System.out.print(res); } public static int solution(int x, int y, int n) { if (x == y) return 0; Queue queue = new LinkedList(); int[] exists = new int[1000001]; queue.a.. 2023. 7. 28. 이전 1 다음 반응형