905. Sort Array By Parity Easy

@problem@discussion
#Array#Two Pointers#Sorting



1/**
2 * [905] Sort Array By Parity
3 *
4 * Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers.
5 * Return any array that satisfies this condition.
6 *  
7 * Example 1:
8 * 
9 * Input: nums = [3,1,2,4]
10 * Output: [2,4,3,1]
11 * Explanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
12 * 
13 * Example 2:
14 * 
15 * Input: nums = [0]
16 * Output: [0]
17 * 
18 *  
19 * Constraints:
20 * 
21 * 	1 <= nums.length <= 5000
22 * 	0 <= nums[i] <= 5000
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/sort-array-by-parity/
28// discuss: https://leetcode.com/problems/sort-array-by-parity/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn sort_array_by_parity(nums: Vec<i32>) -> Vec<i32> {
34        vec![]
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_905() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.