Sort Array by Parity Problem

Sort Array by Parity Problem — ExecCode Easy DSA Practice

Solve the Sort Array by Parity problem on ExecCode. Free online easy DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers. Your task is to compute the required answer and return any array that satisfies this condition.

Examples

Input {"nums": [3, 1, 2, 4]}; Output [2,4,3,1]. Input {"nums": [0]}; Output [0]. Input {"nums": [1, 3, 5]}; Output [1,3,5]

Constraints

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

Practice Sort Array by Parity free on ExecCode. Browse DSA problems, topic map, and placement guides.