Find continuous subsequence of an array of integers such that its sum is maximum positive sum.
Solution:
function
maximumSumSubarray(arr){
var
sum=0,max=0,i;
for
(i=0;i<arr.length;i++){
sum = sum + arr[i];
if
(sum<0){
sum=0;
}
if
(max<sum){
max = sum;
}
}
return
max;
}
http://en.wikipedia.org/wiki/Maximum_subarray_problem
http://wuhrr.wordpress.com/category/interview/
http://www.geeksforgeeks.org/archives/19248
No comments:
Post a Comment