728x90


import java.util.*;

public class Solution {
    public List solution(int []arr) {
        List x = new ArrayList<>();

        for(int i = 0; i< arr.length-1; i++){
            if (arr[i]!=arr[i+1]){
                x.add(arr[i]);
            }
        }
        
        x.add(arr[arr.length-1]);
        

        return x;
    }
}
728x90
반응형
복사했습니다!