3 line solution and better than the solution given as a hint


for(int i=0;i<A.length-1;i+=2){
return A[i];


Not linear runtime though. Sorting needs nlog(n)


Motive shouldn’t be just doing the program, it should be doing efficiently.


don’t post this kind of solution just for the sake of bragging…you might haven’t noticed that const vector is given which indicates sorting is not the approach here… Everyone can do with sorting isn’t a big deal…