What is the wrong in this answer


#1

int Solution::solve(vector &A) {
int maxA = INT_MIN, maxB = INT_MIN, maxC = INT_MIN;
int n= A.size();

for (int i = 0; i < n; i++) {  
    if (A[i] > maxA) { 
        maxC = maxB; 
        maxB = maxA; 
        maxA = A[i]; 
    } 
    else if (A[i] > maxB) { 
        maxC = maxB; 
        maxB = A[i]; 
    } 
    else if (A[i] > maxC) 
        maxC = A[i]; 
} 

return (maxA + maxB + maxC);

}


#2

Your program is not satisfying the below condition.
"Maximum sum of triplet ( Ai + Aj + Ak ) such that 0 <= i < j < k < N and Ai < Aj < Ak".


#3

your code gives the sum of three maximum numbers but not sorted according to their indices