Skip to main content
LeetCode 905, Easy. Topics: Array, Two Pointers, Sorting. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 14 parametrized pytest cases, and a playground notebook:

Problem

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

Examples

Constraints

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

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026