Algorithm · Oracle · Medium
You are given an integer array nums. Your task is to reorder the array so that every even-valued element appears before every odd-valued element. To rearrange the array, you may pick any two positions and swap their values. Return the smallest possible number of swaps required to achieve the arrangement. If the array already satisfies the condition, return 0. Note: The internal ordering of even numbers among themselves and odd numbers among themselves does not matter. The…
Checking your access…