-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsSubstructureTest.java
More file actions
38 lines (34 loc) · 1.02 KB
/
IsSubstructureTest.java
File metadata and controls
38 lines (34 loc) · 1.02 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
import org.junit.Test;
public class IsSubstructureTest {
IsSubstructure solver = new IsSubstructure();
@Test
public void test1(){
int[] numsA = {4,2,3,4,5,6,7,8,9};
int[] numsB = {4,8,9};
TreeNode A = TreeNode.numsToTree(numsA);
TreeNode B = TreeNode.numsToTree(numsB);
boolean res = solver.isSubStructure(A, B);
System.out.println(res);
// true
}
@Test
public void test2(){
int[] numsA = {1,0,1,-4,-3};
int[] numsB = {1,-4};
TreeNode A = TreeNode.numsToTree(numsA);
TreeNode B = TreeNode.numsToTree(numsB);
boolean res = solver.isSubStructure(A, B);
System.out.println(res);
// false
}
@Test
public void test3(){
int[] numsA = {10,12,6,8,3,11};
int[] numsB = {10,12,6,8};
TreeNode A = TreeNode.numsToTree(numsA);
TreeNode B = TreeNode.numsToTree(numsB);
boolean res = solver.isSubStructure(A, B);
System.out.println(res);
// true
}
}