We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f93be64 commit 7854087Copy full SHA for 7854087
src/main/java/com/geekidentity/leetcode/n0283/MoveZeroes.java
@@ -0,0 +1,17 @@
1
+package com.geekidentity.leetcode.n0283;
2
+
3
+import com.geekidentity.leetcode.utils.ArrayUtils;
4
5
+/**
6
+ * https://leetcode-cn.com/problems/move-zeroes/
7
+ */
8
+public class MoveZeroes {
9
10
+ public void moveZeroes(int[] nums) {
11
+ if (nums == null || nums.length < 1) return;
12
+ int j = 0;
13
+ for (int i = 0; i < nums.length; i++) {
14
+ if (nums[i] != 0) ArrayUtils.swap(nums, i, j++);
15
+ }
16
17
+}
0 commit comments