Search in sources :

Example 26 with TreeNode

use of com.fishercoder.common.classes.TreeNode in project Leetcode by fishercoder1534.

the class _572Test method test2.

@Test
public void test2() {
    TreeNode s = new TreeNode(3);
    s.left = new TreeNode(4);
    s.right = new TreeNode(5);
    s.left.left = new TreeNode(1);
    s.left.right = new TreeNode(2);
    TreeNode t = new TreeNode(4);
    t.left = new TreeNode(1);
    t.right = new TreeNode(2);
    expected = true;
    actual = solution1.isSubtree(s, t);
    assertEquals(expected, actual);
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 27 with TreeNode

use of com.fishercoder.common.classes.TreeNode in project Leetcode by fishercoder1534.

the class _652Test method test1.

@Test
public void test1() {
    root = new TreeNode(1);
    root.left = new TreeNode(2);
    root.left.left = new TreeNode(4);
    root.right = new TreeNode(3);
    root.right.left = new TreeNode(2);
    root.right.left.left = new TreeNode(4);
    root.right.right = new TreeNode(4);
    TreeNode tree1 = new TreeNode(2);
    tree1.left = new TreeNode(4);
    TreeNode tree2 = new TreeNode(4);
    expected = new ArrayList<>(Arrays.asList(tree2, tree1));
    assertEquals(expected, test.findDuplicateSubtrees(root));
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 28 with TreeNode

use of com.fishercoder.common.classes.TreeNode in project Leetcode by fishercoder1534.

the class _652Test method test3.

@Test
public void test3() {
    root = new TreeNode(2);
    root.left = new TreeNode(1);
    root.right = new TreeNode(1);
    TreeNode tree1 = new TreeNode(1);
    expected = new ArrayList<>(Arrays.asList(tree1));
    assertEquals(expected, test.findDuplicateSubtrees(root));
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 29 with TreeNode

use of com.fishercoder.common.classes.TreeNode in project Leetcode by fishercoder1534.

the class _653Test method test3.

@Test
public void test3() {
    root = new TreeNode(1);
    expected = false;
    assertEquals(expected, listSolution.findTarget(root, 2));
    assertEquals(expected, mapSolution.findTarget(root, 2));
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 30 with TreeNode

use of com.fishercoder.common.classes.TreeNode in project Leetcode by fishercoder1534.

the class _98Test method test3.

@Test
public void test3() {
    root = new TreeNode(1);
    root.left = new TreeNode(1);
    assertEquals(false, solution1.isValidBST(root));
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Aggregations

TreeNode (com.fishercoder.common.classes.TreeNode)39 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)7 LinkedList (java.util.LinkedList)6 HashMap (java.util.HashMap)2 List (java.util.List)2 Before (org.junit.Before)2 ArrayDeque (java.util.ArrayDeque)1 TreeMap (java.util.TreeMap)1 Ignore (org.junit.Ignore)1