데일리 루틴
49번 - 두개 뽑아서 더하기
https://school.programmers.co.kr/learn/courses/30/lessons/68644
function solution(numbers) {
var answer = [];
for(let i=0; i<numbers.length; i++){
for(let j=i+1; j<numbers.length; j++){
const sum = numbers[i] + numbers[j];
if(!answer.includes(sum))
answer.push(sum);
answer.sort((a,b)=> a - b);
}
}
return answer;
}
50번 - 가장 가까운 같은 글자
https://school.programmers.co.kr/learn/courses/30/lessons/142086
function solution(s) {
var answer = [];
const view = new Map;
for(let i=0; i<s.length; i++){
if(view.get(s[i]) === undefined)
answer.push(-1);
else
answer.push(i - view.get(s[i]));
view.set(s[i], i);
}
return answer;
}