Showing posts with label Leetcode 333: Largest BST subtree. Show all posts
Showing posts with label Leetcode 333: Largest BST subtree. Show all posts

Wednesday, March 14, 2018

Learn the first time Leetcode 333: Largest BST subtree

March 14, 2018

Introduction


It is the first time I learn the algorithm called Leetcode 333: Largest BST subtree. What I like to do is to quickly go over one coding blog about the algorithm, and then spend some time to go over the analysis. I chose the blog since the author wrote down his analysis and it is very helpful for me to understand the algorithm.

I review the analysis in Chinese and then put them in a gist.

Code review


Here is the gist link.

As a programmer, I think that it is more important for me to write down analysis for the algorithm. What I like to train myself is to be able to analyze the algorithm in great detail. Best thing to do is to find a coding blog and then go over word by word.



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.


Tuesday, March 13, 2018

Leetcode 333: Largest BST subtree

March 13, 2018


Introduction


I just came cross the algorithm called Leetcode 333: Find largest binary search tree, and then I had chance to interview the peer in mock interview. He did very good job to explain the algorithm, write pseudo code, and also explain the algorithm using the test case to me.


Code review


I will review the algorithm and mock interview transcript later on. Here is the link.

Here is my C# practice based on the coding blog using optimal time complexity O(N).

Leetcode 333: Largest BST subtree

March 13, 2018

Plan to study the algorithm based on the coding blog here.