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
- string
- array
- Number Theory
- Counting
- simulation
- 코딩테스트
- Binary Tree
- 파이썬
- Class
- SQL
- 구현
- dynamic programming
- geometry
- Binary Search
- 자바
- java
- 코테
- Data Structure
- Stack
- bit manipulation
- implement
- hash table
- greedy
- Tree
- Math
- Matrix
- sorting
- database
- two pointers
- Method
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2446. Determine if Two Events Have Conflict 본문
1. Input
1) String[] event1
2) String[] event2
2. Output
1) 두 행사의 시간이 겹치면 true, 겹치지 않으면 false를 반환
3. Constraint
1) evnet1.length == event2.length == 2.
2) event1[i].length == event2[i].length == 5
3) startTime1 <= endTime1
4) startTime2 <= endTime2
5) 모든 시간은 유효한 HH:MM 형식으로 되어있다.
4. Example
Input: event1 = ["01:15","02:00"], event2 = ["02:00","03:00"] -> Output: true
Input: event1 = ["01:00","02:00"], event2 = ["01:20","03:00"] -> Output: true
Input: event1 = ["10:00","11:00"], event2 = ["14:00","15:00"] -> Output: false
5. Code
1) 첫 코드(2023/05/04)
class Solution {
public boolean haveConflict(String[] event1, String[] event2) {
int[] e1 = new int[2], e2 = new int[2];
for(int i=0 ; i<2 ; i++){
e1[i] = Integer.valueOf(event1[i].substring(0,2))*60 + Integer.valueOf(event1[i].substring(3,5));
e2[i] = Integer.valueOf(event2[i].substring(0,2))*60 + Integer.valueOf(event2[i].substring(3,5));
}
return (e1[0]<=e2[0] && e2[0]<=e1[1]) || (e2[0]<=e1[0] && e1[0]<=e2[1]);
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2460. Apply Operations to an Array (0) | 2023.05.04 |
---|---|
[LeetCode/Easy] 2455. Average Value of Even Numbers That Are Divisible by Three (0) | 2023.05.04 |
[LeetCode/Easy] 2441. Largest Positive Integer That Exists With Its Negative (0) | 2023.05.04 |
[프로그래머스/Lv.0] 배열 조각하기 (0) | 2023.05.03 |
[프로그래머스/Lv.1] 예산 (0) | 2023.05.03 |