Search
⌘K
Get Premium
Leetcode 922. Sort Array By Parity II
Rearrange an even-length array that contains exactly half even and half odd numbers so that every even number occupies an even index and every odd number occupies an odd index. Return any ordering that satisfies this index-parity constraint (can be achieved in O(n) time and in-place by swapping mismatched pairs).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.