--- id: 5a23c84252665b21eecc7e84 challengeType: 5 videoUrl: '' title: 最重要的后续总和 --- ## Description
给定一个整数序列,找到一个连续的子序列,它最大化其元素的总和,也就是说,没有其他单个子序列的元素加起来大于这一个的值。空子序列被认为具有\(0 \)的总和;因此,如果所有元素都是负数,则结果必须是空序列。
## Instructions
## Tests
```yml tests: - text: maximumSubsequence应该是一个函数。 testString: assert(typeof maximumSubsequence=='function'); - text: 'maximumSubsequence("+JSON.stringify(tests[0])+")应该返回一个数组。' testString: assert(Array.isArray(maximumSubsequence([ 1, 2,-1, 3, 10, -10 ]))); - text: 'maximumSubsequence("+JSON.stringify(tests[0])+")应返回"+JSON.stringify(results[0])+" 。' testString: assert.deepEqual(maximumSubsequence([1,2,-1,3,10,-10]), [ 1, 2, -1, 3, 10 ]); - text: 'maximumSubsequence("+JSON.stringify(tests[1])+")应返回"+JSON.stringify(results[1])+" 。' testString: assert.deepEqual(maximumSubsequence([0, 8, 10, -2, -4, -1, -5, -3]), [ 0, 8, 10 ]); - text: 'maximumSubsequence("+JSON.stringify(tests[2])+")应返回"+JSON.stringify(results[2])+" 。' testString: assert.deepEqual(maximumSubsequence([ 9, 9, -10, 1 ]), [ 9, 9 ]); - text: 'maximumSubsequence("+JSON.stringify(tests[3])+")应返回"+JSON.stringify(results[3])+" 。' testString: assert.deepEqual(maximumSubsequence([ 7, 1, -5, -3, -8, 1 ]), [ 7, 1 ]); - text: 'maximumSubsequence("+JSON.stringify(tests[4])+")应返回"+JSON.stringify(results[4])+" 。' testString: assert.deepEqual(maximumSubsequence([ -3, 6, -1, 4, -4, -6 ]), [ 6, -1, 4 ]); - text: 'maximumSubsequence("+JSON.stringify(tests[5])+")应返回"+JSON.stringify(results[5])+" 。' testString: assert.deepEqual(maximumSubsequence([ -1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1 ]), [ 3, 5, 6, -2, -1, 4 ]); ```
## Challenge Seed
```js function maximumSubsequence (population) { // Good luck! } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ``` /section>