Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Largest Sum Contiguous Subarray in Range




static void update(int arr[], int arrSize, int index, int value)
{
   // Your code here
   arr[index-1]=value;
}

//Funciton to return the Maximum-Sum in the range.
static int query(int arr[], int n, int left, int right) 
{
   // code here
    int curr=arr[left-1];
       int sum=arr[left-1];
       for (int i=left;i<right;i++){
           sum=Math.max(arr[i], sum+arr[i]);
           curr=Math.max(curr,sum);
       }
       return curr;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Largest #Sum #Contiguous #Subarray #Range
ADD COMMENT
Topic
Name
4+3 =