Skip to content

Commit a0cd1a2

Browse files
authored
Update 001.js
1 parent 8bdd269 commit a0cd1a2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ch01/001.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
function test() {}
1+
function LSS(list) {
2+
const len = list.length;
3+
let max = -Number.MAX_VALUE;
4+
let sum = 0;
5+
for (let i = 0; i < len; i++) {
6+
sum = 0;
7+
for (let j = i; j < len; j++) {
8+
sum += list[j];
9+
if (sum > max) {
10+
max = sum;
11+
}
12+
}
13+
}
14+
15+
return max;
16+
}

0 commit comments

Comments
 (0)