Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- string
- Data Structure
- sorting
- Tree
- bit manipulation
- Number Theory
- Counting
- Binary Search
- SQL
- geometry
- database
- array
- hash table
- simulation
- implement
- greedy
- 구현
- 코테
- java
- Method
- two pointers
- Stack
- dynamic programming
- 파이썬
- Matrix
- Math
- Class
- 코딩테스트
- 자바
- Binary Tree
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2651. Calculate Delayed Arrival Time 본문
1. Input
1) int arrivalTime
2) int delayedTime
2. Output
1) 기차가 출발하는 시간을 24시간 형식으로 반환
3. Constraint
1) 1 <= arrivaltime < 24
2) 1 <= delayedTime <= 24
4. Example
Input: arrivalTime = 15, delayedTime = 5 -> Output: 20
설명: 15시에 출발 예정이었는데, 5시간이 연기됐으므로 기차는 20시에 출발한다.
5. Code
1) 첫 코드(2023/05/08)
class Solution {
public int findDelayedArrivalTime(int arrivalTime, int delayedTime) {
return arrivalTime+delayedTime>=24 ? arrivalTime+delayedTime-24 : arrivalTime+delayedTime;
}
}
- %24로 해봤는데, 이게 성능이 약간 떨어지더라.
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2656. Maximum Sum With Exactly K Elements (0) | 2023.05.08 |
---|---|
[LeetCode/Easy] 2652. Sum Multiples (0) | 2023.05.08 |
[LeetCode/Easy] 2644. Find the Maximum Divisibility Score (0) | 2023.05.08 |
[LeetCode/Easy] 2643. Row With Maximum Ones (0) | 2023.05.08 |
[LeetCode/Easy] 2639. Find the Width of Columns of a Grid (0) | 2023.05.08 |