FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3778,3 "name": "transform-array-by-parity",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/transform-array-by-parity/",6 "date": "2025-02-15",7 "task_description": "You are given an integer array `nums`. Transform `nums` by performing the following operations in the **exact** order specified: Replace each even number with 0. Replace each odd numbers with 1. Sort the modified array in **non-decreasing** order. Return the resulting array after performing these operations. **Example 1:** **Input:** nums = [4,3,2,1] **Output:** [0,0,1,1] **Explanation:** Replace the even numbers (4 and 2) with 0 and the odd numbers (3 and 1) with 1. Now, `nums = [0, 1, 0, 1]`. After sorting `nums` in non-descending order, `nums = [0, 0, 1, 1]`. **Example 2:** **Input:** nums = [1,5,1,4,2] **Output:** [0,0,1,1,1] **Explanation:** Replace the even numbers (4 and 2) with 0 and the odd numbers (1, 5 and 1) with 1. Now, `nums = [1, 1, 1, 0, 0]`. After sorting `nums` in non-descending order, `nums = [0, 0, 1, 1, 1]`. **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 1000`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [4,3,2,1]",12 "output": "[0,0,1,1] "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,5,1,4,2]",17 "output": "[0,0,1,1,1] "18 }19 ],20 "constraints": [21 "Replace the even numbers (4 and 2) with 0 and the odd numbers (3 and 1) with 1. Now, nums = [0, 1, 0, 1].",22 "After sorting nums in non-descending order, nums = [0, 0, 1, 1].",23 "Replace the even numbers (4 and 2) with 0 and the odd numbers (1, 5 and 1) with 1. Now, nums = [1, 1, 1, 0, 0].",24 "After sorting nums in non-descending order, nums = [0, 0, 1, 1, 1].",25 "1 <= nums.length <= 100",26 "1 <= nums[i] <= 1000"27 ],28 "python_template": "class Solution(object):\n def transformArray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n ",29 "java_template": "class Solution {\n public int[] transformArray(int[] nums) {\n \n }\n}",30 "metadata": {31 "func_name": "transformArray"32 }33}