Practice Transform Array by Parity
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given nums, first replace every even value with 0 and every odd value with 1, then sort the resulting array in nondecreasing order. Return that array.
Source: Transform Array by Parity on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [4,3,2,1]
Output
[0,0,1,1]
# Example 2
Input
nums = [1,5,1,4,2]
Output
[0,0,1,1,1]
Constraints
1 <= nums.length <= 100
1 <= nums[i] <= 1000
Related LeetCode Problems
Practice more problems similar to Transform Array by Parity.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.