but given a node, how to check if it is or not, we should do this: isBalanced(root) = Math.abs(height(root.left) - height(root.right)) < 1 classSolution{publicbooleanisBalanced(TreeNode root){if(root ==null)returntrue;if(Math.abs(height(root.left) - height(root.right)) >1) {...
basic tree construction traversal manipulation algorithms BFS(breadth-first search) and DFS(depth-first search) (video) BFS notes: level order (BFS, using queue) time complexity: O(n) space complexity: best: O(1), worst: O(n/2)=O(n) DFS notes: time complexity: O(n) space complex...