Wednesday, March 14, 2018

Leetcode 333: Largest BST subtree

March 14, 2018

Introduction


It is my favorite practice on recursive function again. The algorithm is not available as free one on leetcode.com, and it is called Largest binary search tree's subtree.

Code practice


What I did is to read some coding blogs, and also practiced once as an interviewer. And also I had chance to ask questions and the peer helped me understand the algorithm very well.

Here is my C# practice. Since I do not have chance to run against all test cases, I may think about posting a code review on stackexchange.com. The time complexity is optimal one with O(n) where n is number of nodes in the tree.


Actionable Items


I studied one of coding blogs, and based on the author, there are two more algorithms with O(n2) time complexity. I plan to practice those ideas as well.


No comments:

Post a Comment