public static ArrayList<Integer> solution( int[] arr){
ArrayList<Integer> answer = new ArrayList<>();
Stack<Integer> st = new Stack<>();
for(int i=0; i<arr.length; i++){
if(!st.empty() && st.peek() == arr[i]) st.pop();
st.push(arr[i]);
}
for(int s : st) answer.add(s);
return answer;
}