UpDown Dev Story
위 문제는 둘째줄에 문자에 정렬된 형식에 맞춰서 첫째줄에 입력받은 숫자들도 정렬해주면 되는 문제이다 import java.util.*; public class BOJ3047 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] arr = new int[3]; for (int i = 0; i < arr.length; i++) { arr[i] = sc.nextInt(); } String s = sc.next(); Arrays.sort(arr); for (int j = 0; j < arr.length; j++) { if ('A' == s.charAt(j)) { System.out.print(arr[0] + " ..
위 문제는 쉽게말하면 기본적으로 x좌표가 증가하는 순으로 정렬하고 x좌표가 같으면 y좌표가 증가하는 순으로 정렬하는 문제입니다 import java.util.*; public class BOJ11650 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.nextLine()); int[][] arr = new int[N][2]; for (int i = 0; i < N; i++){ for (int j = 0; j < arr[i].length; j++){ arr[i][j] = sc.nextInt(); } } Arrays.sort(arr, new Comparator() {..
N 개의 단어를 받아서 1. 길이가 짧은 것부터 2. 길이가 같으면 사전 순으로 정렬하여 출력하는 문제입니다. 하지만 문제를 자세히 읽어보면 중복된 단어의 경우 한번만 출력한다는 조건이 하나 더 있습니다. 그래서 입력받은 문자를 Set 자료구조에 담아서 중복을 제거한 뒤에 ArrayList로 옮겨서 정렬해주었습니다. import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.nextLine()); // 중복 제거를 위해 set으로 먼저 input Set set = new HashSet(); for (int..