-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLC729.java
More file actions
58 lines (46 loc) · 1.37 KB
/
LC729.java
File metadata and controls
58 lines (46 loc) · 1.37 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* LC729
*/
import java.util.*;
class MyCalendar {
TreeMap<Integer, Integer> map;
public MyCalendar() {
map = new TreeMap<>();
}
public boolean book(int start, int end) {
Integer preVal = map.lowerKey(end);
if (preVal != null && start <= map.get(preVal) - 1) {
return false;
}
map.put(start, end);
return true;
}
}
public class LC729 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the Array-1 Size : ");
int size = sc.nextInt();
System.out.println();
String arr[] = new String[size];
System.out.println("Enter Array Elements : ");
for (int i = 0; i < arr.length; i++) {
System.out.printf("[%d] : ", i);
arr[i] = sc.nextLine();
}
System.out.println();
System.out.print("Enter the Array-2D Size : ");
int size1 = sc.nextInt();
System.out.println();
int ar[][] = new int[size][size];
System.out.println("Enter 2-D Array Elements : ");
for (int i = 0; i < ar.length; i++) {
for (int j = 0; j < ar.length; j++) {
System.out.printf("[%d][%d] : ", i, j);
ar[i][j] = sc.nextInt();
}
}
System.out.println();
sc.close();
}
}