283. Move Zeroes Easy

@problem@discussion
#Array#Two Pointers



1/**
2 * [283] Move Zeroes
3 *
4 * Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
5 * Note that you must do this in-place without making a copy of the array.
6 *  
7 * Example 1:
8 * Input: nums = [0,1,0,3,12]
9 * Output: [1,3,12,0,0]
10 * Example 2:
11 * Input: nums = [0]
12 * Output: [0]
13 *  
14 * Constraints:
15 * 
16 * 	1 <= nums.length <= 10^4
17 * 	-2^31 <= nums[i] <= 2^31 - 1
18 * 
19 *  
20 * Follow up: Could you minimize the total number of operations done?
21 */
22pub struct Solution {}
23
24// problem: https://leetcode.com/problems/move-zeroes/
25// discuss: https://leetcode.com/problems/move-zeroes/discuss/?currentPage=1&orderBy=most_votes&query=
26
27// submission codes start here
28
29impl Solution {
30    pub fn move_zeroes(nums: &mut Vec<i32>) {
31        
32    }
33}
34
35// submission codes end
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn test_283() {
43    }
44}
45


Back
© 2025 bowen.ge All Rights Reserved.