-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintersection_of_array.js
More file actions
41 lines (35 loc) · 955 Bytes
/
Copy pathintersection_of_array.js
File metadata and controls
41 lines (35 loc) · 955 Bytes
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
function runProgram(input){
var input_arr = input.trim().split(/[\r\n]+/)
var array1 = input_arr[1].split(" ").map(function(e){ return Number(e)})
var array2 = input_arr[2].split(" ").map(function(e){ return Number(e)})
var common_no = array1.forEach(
function(e)
{
array2.forEach(
function(f)
{
if(e == f)
{
console.log(e)
}
}
)
}
)
common_no
}
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$/,"")
runProgram(read);
});
process.on("SIGINT", function () {
read = read.replace(/\n$/,"")
runProgram(read);
process.exit(0);
});