Comment body goes here.

What is the problem with this Approach?

int Solution::solve(vector &A, int B) {

int p1 = 0,p2 = A.size(),sum = 0;

while(B >= 0 && p1 <= p2) {

if(A[p1] >= A[p2]) {

sum += A[p1];

p1++;

B–;

}

else {

sum += A[p2];

p2–;

B–;

}

}

return sum;

}