2651.Calculate Delayed Arrival Time, Time complexity: O(1), Space complexity: O(1)
IntuitionThe problem involves calculating the final arrival time of a train, considering a potential delay. Since time works cyclically over a 24-hour period, t
# Intuition
The problem involves calculating the final arrival time of a train, considering a potential delay. Since time works cyclically over a 24-hour period, the result should always remain within this range. The solution leverages modular arithmetic to ensure that the computed time wraps around correctly once it reaches 24 hours.

# Approach
**1.Input Parameters:**

**arrivalTime:** The initial arrival time of the train, given in hours (0 to 23).

**delayedTime:** The delay added to the arrival time, also in hours.

**2.Sum the Times:**
The sum of arrivalTime and delayedTime is calculated to get the total time the train will arrive after accounting for the delay.

**3.Modular Arithmetic:**
The sum may exceed 24 hours, which would take it out of the 24-hour clock range. To handle this, the result is taken modulo 24. This operation ensures that if the total time goes beyond 23 (the last hour in a day), it wraps around to start from 0 again.

**4.Return the Result:**
The final result, which is within the 0 to 23 range, is returned as the correct arrival time considering the delay.

**Detailed Example**
Suppose arrivalTime = 22 (10 PM) and delayedTime = 5.
The sum is 22 + 5 = 27.
Since 27 exceeds 24, we apply 27 % 24 = 3.
Therefore, the train arrives at 3 AM the next day.

# Complexity
- Time complexity:
O(1), because the operation involves only basic arithmetic and a single modulo operation, regardless of the input size.

- Space complexity:
O(1), as the method uses a constant amount of space, with no extra data structures.

# Code
```java []
class Solution {
    public int findDelayedArrivalTime(int arrivalTime, int delayedTime) {
        return(arrivalTime+delayedTime)%24;
    }
}
```

```C++ []
class Solution {
public:
    int findDelayedArrivalTime(int arrivalTime, int delayedTime) {
        return(arrivalTime+delayedTime)%24;
    }
};
```
```Python3 []
class Solution:
    def findDelayedArrivalTime(self, arrivalTime: int, delayedTime: int) -> int:
        return(arrivalTime+delayedTime)%24;
```


['Math', 'C++', 'Java', 'Python3']