Amdocs Interview Question

Find the first and second maximum of an array in one loop

Interview Answers

Anonymous

May 24, 2015

I gave them the code

8

Anonymous

Jan 22, 2017

int max=arr[0]; int smax=max; int flag=0; for(int i=0;imax){ flag=1; } if(flag==1) { smax=max; max=arr[i]; flag=0; } }