Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
function MaximumSubsequence(population) {
|
||||
var maxValue = 0;
|
||||
var subsequence = [];
|
||||
|
||||
for (var i = 0, len = population.length; i < len; i++) {
|
||||
for (var j = i; j <= len; j++) {
|
||||
var subsequence = population.slice(i, j);
|
||||
var value = sumValues(subsequence);
|
||||
if (value > maxValue) {
|
||||
maxValue = value;
|
||||
greatest = subsequence;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return greatest;
|
||||
}
|
||||
|
||||
function sumValues(arr) {
|
||||
var result = 0;
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
result += arr[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue