5 kyu
Longest sequence with zero sum
483 of 783romanzes
Description:
Write a method that takes an array of signed integers, and returns the longest contiguous subsequence of this array that has a total sum of elements of exactly 0
.
If more than one equally long subsequences have a zero sum, return the one starting at the highest index.
For example:maxZeroSequenceLength([25, -35, 12, 6, 92, -115, 17, 2, 2, 2, -7, 2, -9, 16, 2, -11])
should return[92, -115, 17, 2, 2, 2]
, because this is the longest zero-sum sequence in the array.
Arrays
Algorithms
Similar Kata:
Stats:
Created | Dec 20, 2013 |
Published | Dec 20, 2013 |
Warriors Trained | 1542 |
Total Skips | 104 |
Total Code Submissions | 6016 |
Total Times Completed | 783 |
JavaScript Completions | 483 |
CoffeeScript Completions | 43 |
Python Completions | 271 |
Total Stars | 50 |
% of votes with a positive feedback rating | 88% of 164 |
Total "Very Satisfied" Votes | 132 |
Total "Somewhat Satisfied" Votes | 24 |
Total "Not Satisfied" Votes | 4 |