142086
Link
https://school.programmers.co.kr/learn/courses/30/lessons/142086 (opens in a new tab)
Answer
JavaScript
function solution(s) {
const hash = {};
return [...s].map((v, i) => {
let result = hash[v] !== undefined ? i - hash[v] : -1;
hash[v] = i;
return result;
});
}