Skip to content

Instantly share code, notes, and snippets.

View poperechnyi1's full-sized avatar
🏠
Working from home

Stepan Poperechnyi poperechnyi1

🏠
Working from home
  • Warsaw
View GitHub Profile
var maxSequence = function(arr){
var curr_max = 0, max_so_far = 0;
for(var i = 0; i < arr.length; i++){
curr_max = Math.max(0, curr_max + arr[i]);
max_so_far = Math.max(curr_max, max_so_far);
}
return max_so_far;
}