Beispiel #1
0
 def test_single_node(self):
     self.assertListEqual(to_list(invertTree(TreeNode(1))), [1])
 def test_one_none_other_not(self):
     self.assertFalse(isSameTree(None, TreeNode(1)))
 def test_same_single_value(self):
     self.assertTrue(isSameTree(TreeNode(1), TreeNode(1)))
 def test_single_node_with_sum(self):
     self.assertTrue(hasPathSum(TreeNode(1), 1))
 def test_single_node_no_sum(self):
     self.assertFalse(hasPathSum(TreeNode(1), 22))
Beispiel #6
0
 def test_single_node(self):
     self.assertEqual(minDepth(TreeNode(1)), 1)
Beispiel #7
0
 def test_empty_in_single_node(self):
     self.assertTrue(isSubtree(TreeNode(1), None))
 def test_node_plus_node(self):
     self.assertEqual(mergeTrees(TreeNode(1), TreeNode(2)).val, 3)
Beispiel #9
0
 def test_single_node(self):
     self.assertListEqual(binaryTreePaths(TreeNode(1)), ["1"])
 def test_node_plus_none(self):
     self.assertEqual(mergeTrees(TreeNode(1), None).val, 1)
 def test_none_plus_node(self):
     self.assertEqual(mergeTrees(None, TreeNode(1)).val, 1)
 def test_single_node(self):
     self.assertEqual(diameterOfBinaryTree(TreeNode(1)), 0)
Beispiel #13
0
 def test_not_found_in_tree(self):
     self.assertFalse(isSubtree(binarytree([1, 4, 5]), TreeNode(3)))
Beispiel #14
0
 def test_subtree_in_child(self):
     self.assertTrue(isSubtree(binarytree([1, 2, 3]), TreeNode(2)))
 def test_single_node(self):
     self.assertEqual(sumOfLeftLeaves(TreeNode(4)), 0)
Beispiel #16
0
 def test_root_node_only(self):
     self.assert_list_of_lists_equal(zigzagLevelOrder(TreeNode(1)), [[1]])
Beispiel #17
0
 def test_single_node(self):
     self.assertTrue(isBalanced(TreeNode(1)))
 def test_single_node(self):
     self.assertTrue(isSymmetric(TreeNode(1)))
 def test_single_node(self):
     self.assertTrue(isUnivalTree(TreeNode(1)))
Beispiel #20
0
 def test_single_node(self):
     self.assertEqual(maxDepth(TreeNode(3)), 1)