프로그래머스 [같은 숫자는 싫어]
문제보기

소스코드
import java.util.ArrayList;
import java.util.List;
public class Solution {
public int[] solution(int []arr) {
List<Integer> checkList = new ArrayList<>();
for (int i = 0; i < arr.length; i++) {
int checkListIdx = checkList.size() - 1;
if (checkListIdx >= 0) {
int beforeValue = checkList.get(checkListIdx);
int currentValue = arr[i];
if (beforeValue == currentValue) continue;
}
checkList.add(arr[i]);
}
int size = checkList.size();
int[] answer = new int[size];
for (int i = 0; i < size; i++) {
answer[i] = checkList.get(i);
}
return answer;
}
}