Skip to content

Commit 08d5d21

Browse files
authored
Update Last Moment Before All Ants Fall Out of a Plank.java
1 parent c69da4f commit 08d5d21

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Solution {
2-
public int getLastMoment(int n, int[] left, int[] right) {
3-
int res = 0;
4-
for (int ant : left) {
5-
res = Math.max(res, ant);
2+
public int getLastMoment(int n, int[] left, int[] right) {
3+
int result = 0;
4+
for (int num : left) {
5+
result = Math.max(result, num);
6+
}
7+
for (int num : right) {
8+
result = Math.max(result, n - num);
9+
}
10+
return result;
611
}
7-
for (int ant : right) {
8-
res = Math.max(res, n - ant);
9-
}
10-
return res;
11-
}
1212
}

0 commit comments

Comments
 (0)