3467. Transform Array by Parity Easy
1/**
2 * [3467] Transform Array by Parity
3 *
4 * You are given an integer array nums. Transform nums by performing the following operations in the exact order specified:
5 * <ol>
6 * Replace each even number with 0.
7 * Replace each odd numbers with 1.
8 * Sort the modified array in non-decreasing order.
9 * </ol>
10 * Return the resulting array after performing these operations.
11 *
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">nums = [4,3,2,1]</span>
15 * Output: <span class="example-io">[0,0,1,1]</span>
16 * Explanation:
17 *
18 * Replace the even numbers (4 and 2) with 0 and the odd numbers (3 and 1) with 1. Now, nums = [0, 1, 0, 1].
19 * After sorting nums in non-descending order, nums = [0, 0, 1, 1].
20 * </div>
21 * <strong class="example">Example 2:
22 * <div class="example-block">
23 * Input: <span class="example-io">nums = [1,5,1,4,2]</span>
24 * Output: <span class="example-io">[0,0,1,1,1]</span>
25 * Explanation:
26 *
27 * 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].
28 * After sorting nums in non-descending order, nums = [0, 0, 1, 1, 1].
29 * </div>
30 *
31 * Constraints:
32 *
33 * 1 <= nums.length <= 100
34 * 1 <= nums[i] <= 1000
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/transform-array-by-parity/
40// discuss: https://leetcode.com/problems/transform-array-by-parity/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn transform_array(nums: Vec<i32>) -> Vec<i32> {
46 vec![]
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_3467() {
58 }
59}
60Back
© 2026 bowen.ge All Rights Reserved.