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 |
Tags
- Data Structure
- 파이썬
- bit manipulation
- Math
- Method
- 코테
- 구현
- string
- Number Theory
- 자바
- Binary Search
- Tree
- java
- sorting
- implement
- dynamic programming
- Class
- Counting
- Binary Tree
- Stack
- simulation
- two pointers
- Matrix
- greedy
- geometry
- array
- hash table
- SQL
- database
- 코딩테스트
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1736. Latest Time by Replacing Hidden Digits 본문
1. Input
1) String time
2. Output
1) time의 ?을 숫자로 바꿨을 때 가장 늦은 시간을 나타내는 문자열을 반환
3. Constraint
1) time은 00:00부터 23:59까지의 시간을 나타내는 문자열이다.
2) 항상 유효한 답이 있다는 것이 보장된다.
4. Example
Input: time = "2?:?0" -> Output: "23:50"
Input: time = "0?:3?" -> Output: "09:39"
5. Code
1) 첫 코드(2023/04/16)
char[] t = time.toCharArray();
if(t[0]=='?'){
if(t[1]=='?'){
t[0] = '2'; t[1] = '3';
} else if(t[1]<='3')
t[0] = '2';
else
t[0] = '1';
} else if(t[1]=='?'){
if(t[0]=='2')
t[1] = '3';
else
t[1] = '9';
}
if(t[3]=='?')
t[3] = '5';
if(t[4]=='?')
t[4] = '9';
return new String(t);
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[백준 온라인 저지] 2941. 크로아티아 알파벳 (0) | 2023.04.17 |
---|---|
[LeetCode/Easy] 1748. Sum of Unique Elements (0) | 2023.04.17 |
[LeetCode/Easy] 1694. Reformat Phone Number (0) | 2023.04.16 |
[LeetCode/Easy] 1652. Defuse the Bomb (0) | 2023.04.15 |
[LeetCode/Easy] 1646. Get Maximum in Generated Array (0) | 2023.04.15 |