We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 273a5f9 commit 49b380eCopy full SHA for 49b380e
src/main/java/g1701_1800/s1776_car_fleet_ii/Solution.java
@@ -9,15 +9,12 @@
9
public class Solution {
10
public double[] getCollisionTimes(int[][] cars) {
11
Deque<Integer> stack = new LinkedList<>();
12
-
13
int n = cars.length;
14
double[] ans = new double[n];
15
16
for (int i = n - 1; i >= 0; i--) {
17
ans[i] = -1.0;
18
int[] presentCar = cars[i];
19
int presentCarSpeed = presentCar[1];
20
21
while (!stack.isEmpty()) {
22
int previousCar = stack.peekLast();
23
int previousCarSpeed = cars[previousCar][1];
@@ -29,10 +26,8 @@ public double[] getCollisionTimes(int[][] cars) {
29
26
}
30
27
stack.pollLast();
31
28
32
33
stack.offerLast(i);
34
35
36
return ans;
37
38
0 commit comments