Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf937b5a

Browse files
authored
Update Asteroid Collision.java
1 parent12cbf33 commitf937b5a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

‎Medium/Asteroid Collision.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ public int[] asteroidCollision(int[] asteroids) {
1010
if (stack.peek() ==Math.abs(asteroid)) {
1111
stack.pop();
1212
}
13-
}
14-
else {
13+
}else {
1514
stack.push(asteroid);
1615
}
17-
}
18-
else {
16+
}else {
1917
stack.push(asteroid);
2018
}
2119
}
22-
int[]state =newint[stack.size()];
23-
for (inti =state.length -1;i >=0;i--) {
24-
state[i] =stack.pop();
20+
int[]result =newint[stack.size()];
21+
for (inti =result.length -1;i >=0;i--) {
22+
result[i] =stack.pop();
2523
}
26-
returnstate;
24+
returnresult;
2725
}
2826
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp