Skip to content

Commit 72b5f52

Browse files
coffe1891gitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent 86f5e6d commit 72b5f52

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

2/2.1.7.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ fn([-1, -2, -3, -4, -9, -8]);//>> -1
7878

7979
```javascript
8080
function fn(array) {
81-
if(array == null && array.length <= 0) {
82-
return 0;
83-
}
84-
let Maxsum = Integer.MIN_VALUE;
85-
let currentSum = 0;
86-
for(let i=0; i<array.length; i++) {
87-
currentSum += array[i];
88-
if(currentSum < array[i]) {
89-
currentSum = array[i];
90-
}
91-
if(currentSum > Maxsum) {
92-
Maxsum = currentSum;
93-
}
81+
if (array == null && array.length <= 0) {
82+
return 0;
83+
}
84+
let Maxsum = Integer.MIN_VALUE;
85+
let currentSum = 0;
86+
for (let i = 0; i < array.length; i++) {
87+
currentSum += array[i];
88+
if (currentSum < array[i]) {
89+
currentSum = array[i];
9490
}
95-
return Maxsum;
91+
if (currentSum > Maxsum) {
92+
Maxsum = currentSum;
93+
}
94+
}
95+
return Maxsum;
9696
}
9797
```
9898

0 commit comments

Comments
 (0)