Partition and Group Values by Parity
Problem statement
Given an integer array nums, return two groups: all even values in their original order, followed by all odd values in their original order.
The result must always contain exactly two rows. Either row may be empty.
Function
partitionByParity(nums: int[]) → int[][]Examples
Example 1
nums = [3,2,4,1,0]return = [[2,4,0],[3,1]]The first row contains stable evens and the second contains stable odds.
Example 2
nums = [2,4]return = [[2,4],[]]The odd group is empty.
Constraints
0 <= nums.length <= 100000.-10^9 <= nums[i] <= 10^9.
Source note: Author-written prompt excerpt retained for source fidelity.