Skip to content

Commit a053062

Browse files
committed
Runtime: 154 ms (Top 97.67%) | Memory: 53.7 MB (Top 79.07%)
1 parent df6c8c6 commit a053062

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/algorithms/M/Minimum Speed to Arrive on Time/Minimum Speed to Arrive on Time.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// Runtime: 154 ms (Top 97.67%) | Memory: 53.7 MB (Top 79.07%)
12
var minSpeedOnTime = function(dist, hour) {
23
let left=1,right=10000000,speed,sum,ans=-1;
34
while(left<=right){
4-
//We need to return the minimum positive integer speed (in kilometers per hour) that all the trains must travel. So speed will always be an integer ranging from 1 to 10000000 as per the question description.
5+
//We need to return the minimum positive integer speed (in kilometers per hour) that all the trains must travel. So speed will always be an integer ranging from 1 to 10000000 as per the question description.
56
speed = left + Math.floor((right-left)/2);
67
sum=0;
78
for(let i=0;i<dist.length-1;i++){
@@ -16,4 +17,4 @@ var minSpeedOnTime = function(dist, hour) {
1617
}
1718
}
1819
return ans;
19-
};
20+
};

0 commit comments

Comments
 (0)