You are a passport issuer, but due to some problems in the system, there are redundant passport numbers. Your task is to delete all the duplicate passport numbers. You are given a list of passport numbers.
Sample Input : 5 A23 B56 B56 C79 D16
Sample Output : A23 B56 C79 D16
Sample Input : 5 A23 B56 B56 C79 D16
B56 B56 C79 B56
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () =>
{var a = parseInt(userInput[0]);
var inp = String(userInput[1]);
var arr = inp.split(" ")
for(i=0;i<a;i++)
{
for(j=i+1;j<a;j++)
{
if(arr[i]==arr[j])
arr.splice(i,1)
i-- //try without this line
console.log(arr)
}
}
var str=arr.join(" ")
console.log(str);
});
Comments
Post a Comment