Search in sources :

Example 21 with TreeNode

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

the class _501Test method test1.

@Test
public void test1() {
    treeNode = new TreeNode(1);
    treeNode.right = new TreeNode(2);
    treeNode.right.left = new TreeNode(2);
    expected = new int[] { 2 };
    CommonUtils.printArray(expected);
    CommonUtils.printArray(actual);
    actual = solution1.findMode(treeNode);
    assertArrayEquals(expected, actual);
    actual = solution2.findMode(treeNode);
    assertArrayEquals(expected, actual);
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 22 with TreeNode

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

the class _515Test method test1.

@Test
public void test1() {
    TreeNode root = new TreeNode(1);
    root.left = new TreeNode(3);
    root.right = new TreeNode(2);
    expected = Arrays.asList(1, 3);
    actual = solution1.largestValues(root);
    assertEquals(expected, actual);
    actual = solution2.largestValues(root);
    assertEquals(expected, actual);
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 23 with TreeNode

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

the class _538Test method test1.

@Test
public void test1() {
    root = new TreeNode(5);
    root.left = new TreeNode(2);
    root.right = new TreeNode(13);
    expectedRoot = new TreeNode(18);
    expectedRoot.left = new TreeNode(20);
    expectedRoot.right = new TreeNode(13);
    assertEquals(expectedRoot.toString(), genericSolution.convertBST(root).toString());
    assertEquals(expectedRoot.toString(), bstSolution.convertBST(root).toString());
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 24 with TreeNode

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

the class _563Test method test1.

@Test
public void test1() {
    root = new TreeNode(1);
    root.left = new TreeNode(2);
    root.right = new TreeNode(3);
    expected = 1;
    actual = test.findTilt(root);
    assertEquals(expected, actual);
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 25 with TreeNode

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

the class _572Test method test1.

@Test
public void test1() {
    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);
    s.left.right.left = new TreeNode(0);
    TreeNode t = new TreeNode(4);
    t.left = new TreeNode(1);
    t.right = new TreeNode(2);
    expected = false;
    actual = solution1.isSubtree(s, t);
    assertEquals(expected, actual);
}
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