Given a list of integers nums, rearrange it in place so that every even number comes before every odd number (order inside each group does not matter). Return the number of even values, i.e. the index where the odd values begin.
The tests use evens_odds(nums), which calls evens_first(nums) and, for the returned k, returns (k, sorted(nums[:k]), sorted(nums[k:])).
Examples
Input: nums = [5, 7, 8, 6]
Output: 2; nums becomes e.g. [6, 8, 7, 5]
Input: nums = [1, 3, 5]
Output: 0
Constraints
0 <= len(nums) <= 10**5- Target: O(n) time, O(1) extra space.
Goals
- Partition by a boolean predicate with pointers from both ends
- Return the boundary between the two regions