https://programmers.co.kr/learn/courses/30/lessons/12906
1. 2020
function solution(arr)
{
var answer = [];
var lenArr = arr.length;
answer[0] = arr[0];
for (var i=0; i<lenArr-1; i++){
if (arr[i] !== arr[i+1]){
answer.push(arr[i+1]);
}
}
return answer;
}
1. 2019 - #push구현
function solution(arr){
var answer = [];
answer[0] = arr[0];
var arrLength = arr.length;
for(var i=1; i<arrLength; i++){
var answerLength = answer.length;
if (arr[i] != answer[answerLength-1]){
answer[answerLength] = arr[i];
}
}
return answer;
}
#짧은 풀이는 보통 filter
method를 많이 사용하는 듯