Skip to content

601-Week 01#100

Merged
melody-li merged 1 commit into
algorithm004-01:masterfrom
orajavac:patch-1
Oct 20, 2019
Merged

601-Week 01#100
melody-li merged 1 commit into
algorithm004-01:masterfrom
orajavac:patch-1

Conversation

@orajavac
Copy link
Copy Markdown
Contributor

No description provided.

@JustDoItGit
Copy link
Copy Markdown
Contributor

后面的置零可以优化到第一个for循环里面去做。

class Solution {
public void moveZeroes(int[] nums) {
int j = 0;
for (int i = 0; i<nums.length; i++){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: one space between parenthesis and brace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

public void moveZeroes(int[] nums) {
int j = 0;
for (int i = 0; i<nums.length; i++){
if (nums[i] != 0){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

}

if (j > 0){
while(j < nums.length){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@melody-li melody-li merged commit d8bfb2d into algorithm004-01:master Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants