Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,895 views
in Online Assessments by Expert (110,880 points) | 2,895 views

2 Answers

0 like 0 dislike

Code solution : C++

long long result=LLONG_MIN , total= accumulate(begin(A),end(A),0L), left=0;
for(int i=0;i<n;i++){
   left+= A[i];                       //sum till i from start
   long long right= total-left+A[i];       //sum till i from end
   result= max({result,left,right});  //update global max
}
return res;
by Expert (110,880 points)
0 like 0 dislike

Question asked : 

 

image

image

 

image

 

image

by Expert (110,880 points)