FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JS-code/codility/src/script7.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
/
script7.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
19 lines (19 loc) · 797 Bytes
Breadcrumbs
JS-code
/
codility
/
src
/
script7.js
Copy path
File metadata and controls
19 lines (19 loc) · 797 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
function
solution
(
arr
)
{
const
l
=
arr
.
length
;
const
winterMax
=
[
arr
[
0
]
]
;
const
summerMin
=
[
]
;
summerMin
[
l
-
1
]
=
arr
[
l
-
1
]
;
for
(
let
i
=
1
;
i
<
l
;
i
++
)
{
winterMax
[
i
]
=
Math
.
max
(
winterMax
[
i
-
1
]
,
arr
[
i
]
)
;
summerMin
[
l
-
i
-
1
]
=
Math
.
min
(
summerMin
[
l
-
i
]
,
arr
[
l
-
i
-
1
]
)
;
}
console
.
log
(
"winterMax"
,
winterMax
)
;
console
.
log
(
"summerMin"
,
summerMin
)
;
for
(
let
i
=
1
;
i
<
l
;
i
++
)
{
if
(
winterMax
[
i
-
1
]
<
summerMin
[
i
]
)
return
i
;
}
}
console
.
log
(
"solution([5, -2, 3, 8, 6])"
,
solution
(
[
5
,
-
2
,
3
,
8
,
6
]
)
===
3
)
;
console
.
log
(
"solution([-5, -5, -5, -42, 6, 12]"
,
solution
(
[
-
5
,
-
5
,
-
5
,
-
42
,
6
,
12
]
)
===
4
)
;
console
.
log
(
"solution([1, 1, 1, 1, 1, 2])"
,
solution
(
[
1
,
1
,
1
,
1
,
1
,
2
]
)
===
5
)
;
console
.
log
(
"solution([1, 2, 2, 2, 2, 2])"
,
solution
(
[
1
,
2
,
2
,
2
,
2
,
2
]
)
===
1
)
;
Back
|
FazBrowse Home
|
New Git URL