-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertIntervalTest.java
More file actions
59 lines (52 loc) · 1.38 KB
/
InsertIntervalTest.java
File metadata and controls
59 lines (52 loc) · 1.38 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
59
import org.junit.Test;
import java.util.Arrays;
public class InsertIntervalTest {
InsertInterval solver = new InsertInterval();
@Test
public void test1(){
int[][] intervals = {{1,3},{6,9}};
int[] newInterval = {2,5};
int[][] res = solver.insert(intervals, newInterval);
for(int[] t: res){
System.out.println(Arrays.toString(t));
}
/**
* [1, 5]
* [6, 9]
*/
}
@Test
public void test2(){
int[][] intervals = {{1,2},{3,5},{6,7},{8,10},{12,16}};
int[] newInterval = {4,8};
int[][] res = solver.insert(intervals, newInterval);
for(int[] t: res){
System.out.println(Arrays.toString(t));
}
/**
* [1, 2]
* [3, 10]
* [12, 16]
*/
}
@Test
public void test3() {
int[][] intervals = {};
int[] newInterval = {5, 7};
int[][] res = solver.insert(intervals, newInterval);
for (int[] t : res) {
System.out.println(Arrays.toString(t));
}
// [5, 7]
}
@Test
public void test4() {
int[][] intervals = {{1, 5}};
int[] newInterval = {2, 3};
int[][] res = solver.insert(intervals, newInterval);
for (int[] t : res) {
System.out.println(Arrays.toString(t));
}
// [1, 5]
}
}