Leetcode 2651. Calculate Delayed Arrival Time
Given the arrivalTime
of a train and a delayedTime
in hours, determine the actual arrival time. The arrival time is given in a 24-hour format (0-23). The actual arrival time should also be returned in this format. If the actual arrival time goes beyond 23, it should wrap around to the start of the day (i.e., 24 should be converted to 0, 25 to 1, and so on).
Example:
arrivalTime = 15
, delayedTime = 5
20
Example:
arrivalTime = 23
, delayedTime = 1
0
0 <= arrivalTime <= 23
, delayedTime >= 0
)?arrivalTime
and delayedTime
?public class Solution {
public int findDelayedArrivalTime(int arrivalTime, int delayedTime) {
return (arrivalTime + delayedTime) % 24;
}
}
arrivalTime
and delayedTime
.arrivalTime
and delayedTime
.%
with 24 to ensure the resultant time stays within the 24-hour format.
24 % 24
results in 0
, 25 % 24
results in 1
, etc.).Would you like to proceed with this code, or do you have any additional requirements or clarifications?
Got blindsided by a question you didn’t expect?
Spend too much time studying?
Or simply don’t have the time to go over all 3000 questions?