> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0450_delete_node_in_a_bst/slt.md).

# Solution 1 dfs delete

* t-complexity: O(h) h is the height of the tree
* s-complexity: O(h)

if node is target node:

* if do not have left child, replace it with right child
* if do not have right child, replace it with left child
* if have both children, put left child to right child's left most leaf, and delete it
