Day15-BinaryTree03
110. Balanced Binary Tree
Node:
Time Complexity && Space Complexity
- Time Complexity: O(n)
- Space Complexity: O(n)
1 | var isBalanced = function(root) { |
257. Binary Tree Paths
Node:
Time Complexity && Space Complexity
- Time Complexity: O()
- Space Complexity: O()
1 | var binaryTreePaths = function(root) { |
1 | var binaryTreePaths = function(root) { |
404. Sum of Left Leaves
Node:
Time Complexity && Space Complexity
- Time Complexity: O(n)
- Space Complexity: O(n)
1 | var sumOfLeftLeaves = function(root) { |
1 | var sumOfLeftLeaves = function(root){ |
222. Count Complete Tree Nodes
Node:
- Best case: log(n)
- Worse case: log(n) * log(n)
- Only one node on the left level which is on the most left
- Every node on the most left side on every level(logn) * need be checked for the leftHeigt, rightHeight(logn)
Time Complexity && Space Complexity
- Time Complexity: O(log(n) * log(n))
- Space Complexity: O(logn)
1 | var countNodes = function(root) { |
- Title: Day15-BinaryTree03
- Author: Guoyi
- Created at : 2024-09-19 23:55:55
- Updated at : 2024-12-07 03:58:41
- Link: https://guoyiwang.github.io/Algorithm/Day15-BinaryTree03/
- License: This work is licensed under CC BY-NC-SA 4.0.
Comments