Write a program that removes duplicated strings when N strings are input and outputs them. The output string maintains the original input order.
A natural number N is given in the first line (3<=N<=30). Starting from the second line, N strings are given. The length of the string does not exceed 100.
5
good
time
good
time
student
Outputs the string with duplicates removed from the first line sequentially.
good
time
student
new Set()
function solution(s) {
let answer = [];
new Set(s).forEach((el) => answer.push(el));
return answer;
}
indexOf()
function solution(s) {
let answer = [];
for (let i in s) {
// not ===, using == for not to check the types
if (s.indexOf(s[i]) == i) answer.push(s[i]);
}
return answer;
}
filter()
function solution(s) {
let answer;
answer = s.filter((v, i) => s.indexOf(v) === i);
return answer;
}