GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add 283_Move_Zeroes · Tulpen/Leetcode-Java@21bc078

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitignore
  • Facebook.md
  • Leetcodes.md
  • README.md
  • Solutions/Java
    • 283_Move_Zeroes.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea
Collapse file

‎Facebook.md‎

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Facebook题目列表
2+
------------
3+
4+
[283. Move Zeroes](https://leetcode.com/problems/move-zeroes/)
Collapse file

‎Leetcodes.md‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
所有题目列表
2+
------
3+
[283. Move Zeroes](https://leetcode.com/problems/move-zeroes/)
Collapse file

‎README.md‎

Copy file name to clipboard
+1-2Lines changed: 1 addition & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# leetcode
2-
leetcode java
1+
Leetcode-Java解法
Collapse file

‎Solutions/Java/283_Move_Zeroes.md‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
https://leetcode.com/problems/move-zeroes/
2+
3+
`
4+
这题关键是从前到后遍历,统计有几个0,然后依次给非0的数往前移,最后补零。
5+
`
6+
7+
```
8+
public void moveZeroes(int[] nums) {
9+
int cur = 0;
10+
11+
for (int j = 0; j < nums.length; j++) {
12+
if (nums[j] != 0) {
13+
nums[cur++] = nums[j];
14+
}
15+
}
16+
17+
while (cur < nums.length) {
18+
nums[cur++] = 0;
19+
}
20+
}
21+
```

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.