Skip to content

Commit f937b5a

Browse files
authored
Update Asteroid Collision.java
1 parent 12cbf33 commit f937b5a

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 = new int[stack.size()];
23-
for (int i = state.length - 1; i >= 0; i--) {
24-
state[i] = stack.pop();
20+
int[] result = new int[stack.size()];
21+
for (int i = result.length - 1; i >= 0; i--) {
22+
result[i] = stack.pop();
2523
}
26-
return state;
24+
return result;
2725
}
2826
}

0 commit comments

Comments
 (0)