FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hackerrankSolutions-JavaScript/Search/missingNumbers.js at master · greatnonso7/hackerrankSolutions-JavaScript · GitHub
greatnonso7
/
hackerrankSolutions-JavaScript
Public
forked from
aditiraj/hackerrankSolutions-JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
hackerrankSolutions-JavaScript
/
Search
/
missingNumbers.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (45 loc) · 1.19 KB
Breadcrumbs
hackerrankSolutions-JavaScript
/
Search
/
missingNumbers.js
Copy path
File metadata and controls
54 lines (45 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
processData
(
n
,
arrA
,
m
,
arrB
)
{
var
freq
=
0
;
var
freqInA
=
0
;
var
distArrB
=
[
]
;
var
missingNos
=
[
]
;
arrB
.
sort
(
function
(
a
,
b
)
{
return
a
-
b
}
)
;
distArrB
=
arrB
.
slice
(
)
;
for
(
var
i
=
0
;
i
<
distArrB
.
length
-
1
;
i
++
)
{
for
(
var
j
=
i
+
1
;
j
<
distArrB
.
length
;
j
++
)
{
if
(
distArrB
[
i
]
==
distArrB
[
j
]
)
{
distArrB
.
splice
(
j
,
1
)
;
j
--
;
}
}
}
for
(
var
i
=
0
;
i
<
distArrB
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
m
;
j
++
)
{
if
(
distArrB
[
i
]
==
arrB
[
j
]
)
{
freq
++
;
}
}
for
(
var
k
=
0
;
k
<
n
;
k
++
)
{
if
(
distArrB
[
i
]
==
arrA
[
k
]
)
{
freqInA
++
;
}
}
if
(
freq
!=
freqInA
)
{
missingNos
.
push
(
distArrB
[
i
]
)
;
}
freq
=
0
;
freqInA
=
0
;
}
var
str
=
missingNos
.
join
(
" "
)
;
return
str
;
}
function
main
(
)
{
var
n
=
parseInt
(
readLine
(
)
)
;
arrA
=
readLine
(
)
.
split
(
' '
)
;
arrA
=
arrA
.
map
(
Number
)
;
var
m
=
parseInt
(
readLine
(
)
)
;
arrB
=
readLine
(
)
.
split
(
' '
)
;
arrB
=
arrB
.
map
(
Number
)
;
var
result
=
processData
(
n
,
arrA
,
m
,
arrB
)
;
console
.
log
(
result
)
;
}
Back
|
FazBrowse Home
|
New Git URL