Skip to content

Practice Sort 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.

Easy#905
LeetCode Problem

Sort Array By Parity

Problem Statement

Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers. Return any array that satisfies this condition.

Source: Sort Array By Parity on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,1,2,4]
Output
[2,4,3,1]

# Example 2

Input
nums = [0]
Output
[0]

Constraints

1 <= nums.length <= 5000
0 <= nums[i] <= 5000

Related LeetCode Problems

Practice more problems similar to Sort Array By Parity.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.