Interview Question
Country: India
The answer is quite simple..
You just need to find the count of misplaced even and odd numbers and output the min of those two numbers
if the count of misplaced even and odd are not equal it just means that there are a few numbers that cannot be sorted to even/odd places If you need the program approach reply to this comment
Array should have the same number of even and odd numbers.
- A July 21, 2019A simple sorting algorithm will put the odd numbers in odd indices and even numbers in even indices. It should just return the number of swaps.