1.
int main(){
int max=0;
int max_till_here=0;
for(i=0;i<n;i++){
max_till_here=max_till_here+a[i]; // contiguous sum
if(max_till_here>0){
if(max_till_here>max)
max=max_till_here; // update maximum sum till here
}
else { // in case continuous sum cums to <=0;
max_till_here=0;
}
return max;
}
2. BST ... i think you can start from right child and find 4th largest from
last ... means Right Root and Left order ...
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.