forked from rahul22mrk/hackoctoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Alltime.js
54 lines (48 loc) · 1.14 KB
/
Alltime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function Alltwice(arr){
let obj={}
for(let i=0;i<arr.length;i++){
if(obj[arr[i]]==undefined){
obj[arr[i]] =1
}
else{
obj[arr[i]]+=1
}
}
for (key in obj){
if(obj[key]==1)
console.log(key);
}
}
function runProgram(input) {
let newInput=input.trim().split("\n");
for(let i=1;i<newInput.length;i+=2){
let len = +newInput[i]
let num= newInput[i+1].trim().split(" ")
// console.log(num);
Alltwice(num);
}
}
if (process.env.USERNAME === "ranus") {
runProgram(`2
1
5
5
1 2 1 3 2`);
} else {
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
read += input;
});
process.stdin.on("end", function () {
read = read.replace(/\n$/, "");
read = read.replace(/\n$/, "");
runProgram(read);
});
process.on("SIGINT", function () {
read = read.replace(/\n$/, "");
runProgram(read);
process.exit(0);
});
}