graduate software developer interview questions shared by candidates
Given an array of integers, delete the max and min numbers (both could appear more than once) in place. Do it in O(n) without shifting.
Go through the array twice. In the first run save the min and max, in the second run remove them. Both steps are O(N), so the entire algo is also O(N), it does not matter that the array is walked twice.
1. find max and min in first loop 2. In second loop following if element is min/max = simply increment a counter else a[i-counter] = a[i].
1. find max and min in first loop. 2. In second loop if a[i] is min/max then simply increment a counter else a[i-counter] = a[i].