450 Delete Node in a Bst

450. Delete Node in a BST Idea This brings me back to my university time when we were forced to manually implement heap…… However, this one is simpler but still, not an easy task to do. Basically, the deletion can be divided into two stages: Search for a node to remove. If the node is found, delete the node. The searching part is easy, let’s skip it. How do we delete a node?...

April 21, 2023 · mimimi

110 Balanced Binary Tree

110. Balanced Binary Tree This is an easy problem but I did take quite some time to come out with a relatively elegant (at least to my own eyes) solution. Idea We need to check if the given tree is height balanced. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. We need to find out the depth of the two subtrees(left and right), so we have to use a helper function because obviously the given function has only one parameter....

April 3, 2023 · mimimi