본문 바로가기
Beakjoon&프로그래머스/Java

[프로그래머스/Java] 수열과 구간 쿼리 3

by 현장 2025. 2. 8.

-Code

class Solution {
    public int[] solution(int[] arr, int[][] queries) {
        for (int[] el : queries){
            int temp = arr[el[0]];
            arr[el[0]] = arr[el[1]];
            arr[el[1]] = temp;
        }

        return arr;
    }
}