Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f4082f

Browse files
authored
Fixed formatting 0978-longest-turbulent-subarray.js
1 parent840efec commit5f4082f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

‎javascript/0978-longest-turbulent-subarray.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ var maxTurbulenceSize = function(arr) {
1212
leti=start;
1313
letshouldBeLow=true;
1414

15-
while(i+1<arr.length){
16-
if(shouldBeLow&&arr[i+1]>arr[i])break;
17-
if(!shouldBeLow&&arr[i+1]<arr[i])break;
18-
if(arr[i+1]===arr[i])break;
15+
while(i+1<arr.length){
16+
if(shouldBeLow&&arr[i+1]>arr[i])break;
17+
if(!shouldBeLow&&arr[i+1]<arr[i])break;
18+
if(arr[i+1]===arr[i])break;
1919
shouldBeLow=!shouldBeLow;
2020
i++;
2121
}
@@ -30,10 +30,10 @@ var maxTurbulenceSize = function(arr) {
3030
leti=start;
3131
letshouldBeHigh=true;
3232

33-
while(i+1<arr.length){
34-
if(shouldBeHigh&&arr[i+1]<arr[i])break;
35-
if(!shouldBeHigh&&arr[i+1]>arr[i])break;
36-
if(arr[i+1]===arr[i])break;
33+
while(i+1<arr.length){
34+
if(shouldBeHigh&&arr[i+1]<arr[i])break;
35+
if(!shouldBeHigh&&arr[i+1]>arr[i])break;
36+
if(arr[i+1]===arr[i])break;
3737
shouldBeHigh=!shouldBeHigh;
3838
i++;
3939
}
@@ -46,25 +46,25 @@ var maxTurbulenceSize = function(arr) {
4646
letright=1;
4747
letmax=1;
4848

49-
while(right<arr.length){
49+
while(right<arr.length){
5050

51-
if(arr[left]>arr[right]){
51+
if(arr[left]>arr[right]){
5252
right=higherAndLower(left);
53-
max=Math.max(right-left+1,max);
53+
max=Math.max(right-left+1,max);
5454
left=right;
55-
right=right+1;
55+
right=right+1;
5656
continue;
5757
}
5858

59-
if(arr[left]<arr[right]){
59+
if(arr[left]<arr[right]){
6060
right=lowerAndHigher(left);
61-
max=Math.max(right-left+1,max);
61+
max=Math.max(right-left+1,max);
6262
left=right;
63-
right=right+1;
63+
right=right+1;
6464
continue;
6565
}
6666

67-
if(arr[left]===arr[right]){
67+
if(arr[left]===arr[right]){
6868
left++;
6969
right++;
7070
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp