Search in sources :

Example 6 with TreeNode

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

the class _513Test method test2.

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

Example 7 with TreeNode

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

the class _530Test method test3.

// [543,384,652,null,445,null,699]
@Test
public void test3() {
    root = new TreeNode(543);
    root.left = new TreeNode(384);
    root.right = new TreeNode(652);
    root.left.right = new TreeNode(445);
    root.right.right = new TreeNode(699);
    expected = 47;
    actual = test.getMinimumDifference(root);
    assertEquals(expected, actual);
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Test(org.junit.Test)

Example 8 with TreeNode

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

the class _530Test method test2.

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

Example 9 with TreeNode

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

the class _530Test method test1.

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

Example 10 with TreeNode

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

the class _563Test method test2.

@Ignore
@Test
public void test2() {
    root = new TreeNode(1);
    root.left = new TreeNode(2);
    root.right = new TreeNode(3);
    root.left.left = new TreeNode(4);
    root.right.left = new TreeNode(5);
    expected = 11;
    actual = test.findTilt(root);
    assertEquals(expected, actual);
}
Also used : TreeNode(com.fishercoder.common.classes.TreeNode) Ignore(org.junit.Ignore) 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