Is it possible to find the second maximum number from an array of integers by traversing the array only once?
As an example, I have a array of five integers from whi
You need a second test:
for(int i=0;i<5;i++){ if(arr[i]>max){ second_max=max; max=arr[i]; } else if (arr[i] > second_max && arr[i] != max){ second_max = arr[i]; } }