Find minimum number of exchanges required to arrange n numbers in array such that negative numbers appear before positive ones.

Niket Gangwar @niket151194
23 Aug 2017 07:00 pm

If we pivot the array at the mid-point then worst case is all the negative numbers are after the positive numbers. Now take two pointers one for the front and one for the rear.Every time you have to make a exchange and when front pointer exceeds rear we stop. So in worst case n/2 exchanges.

Ans:- (D)