FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JS-code/codility/src/script4.js at master · Vitaminvp/JS-code · GitHub
Vitaminvp
/
JS-code
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
30
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JS-code
/
codility
/
src
/
script4.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (25 loc) · 808 Bytes
Breadcrumbs
JS-code
/
codility
/
src
/
script4.js
Copy path
File metadata and controls
26 lines (25 loc) · 808 Bytes
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
function
solution
(
N
)
{
const
arr
=
Array
.
from
(
(
N
)
.
toString
(
2
)
)
;
let
maxgap
=
0
;
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
==
1
)
{
let
gap
=
0
;
let
j
=
i
+
1
;
while
(
arr
[
j
]
!==
"1"
&&
arr
[
j
]
&&
arr
[
j
]
<
arr
.
length
)
{
gap
++
;
j
++
}
if
(
maxgap
<
gap
&&
arr
[
j
]
<
arr
.
length
)
maxgap
=
gap
;
console
.
log
(
"i"
,
i
)
;
console
.
log
(
"j"
,
j
)
;
console
.
log
(
"gap"
,
gap
)
;
console
.
log
(
"maxgap"
,
maxgap
)
;
i
=
j
-
1
;
}
}
return
maxgap
;
}
console
.
log
(
"(20).toString(2)"
,
Array
.
from
(
(
328
)
.
toString
(
2
)
)
)
;
console
.
log
(
"solution"
,
solution
(
328
)
)
;
console
.
log
(
"(20).toString(2)"
,
Array
.
from
(
(
1162
)
.
toString
(
2
)
)
)
;
console
.
log
(
"solution"
,
solution
(
1162
)
)
;
Back
|
FazBrowse Home
|
New Git URL