1547号


https://zzang9ha.tistory.com/247
このまま解けば
私の恨み
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        // 1 2 3
        int swap;
        Integer[] array = {1, 2, 3};
        for(int i = 0; i < num ; i++){
            int one = sc.nextInt(); // 3
            int two = sc.nextInt(); // 1

            swap = array[one - 1] ; //  swap = 3 {1, 2, 3]
            array[one-1] = array[two-1]; // {1,2,1}
            array[two-1] = swap; // {3,2,1}
        }

        int idx = Arrays.asList(array).indexOf(1);
        System.out.println(idx+1);


    }
}