Tree
110. Balanced Binary Tree
The naive check — at every node, compute both subtree heights and compare — re-walks subtrees over and over, O(n²). The fix fuses the two jobs (measure height, check balance) into one bottom-up pass,…
Loading…
The naive check — at every node, compute both subtree heights and compare — re-walks subtrees over and over, O(n²). The fix fuses the two jobs (measure height, check balance) into one bottom-up pass,…
Loading…