Introduction
It is most challenging job to manage myself to practice on Leetcode.com. I like to practice 100 algorithms once I know that I will have chance to be phone screened by Facebook again in May, 2019. One of ideas is to rush to work on another 100 algorithms. But reality is that I practice one more mock interview on Leetcode.com, I came cross the algorithm 236 lowest common ancestor. I learn to pace myself to look up and look down, left and right, I put so many topics in this one algorithm practice. I like to share my learning.
So many topics Covered
I learned one more solution, and here is the post.
I solved my first two practice with time out problem applying the idea to find root to p or q path. Here is the solution.
I like to make a list of things I have practiced on this algorithm:
Recursive
1. Using recursive, learn how to define recursive function, simple and clear.
BFS
I also study the code and write a C# solution using BFS to store all nodes with their parent node.
Backtracking
I learn to solve timeout issue in my naive solution in the first practice 2019.
Also backtrack space complexity is much less compared to my naive approach.
Post order traversal - bottom up
How to define a simple and easy recursive function? I learn one solution and like it.
Topics
- BFS
- child-parent map
- Fix naive solution timeout with complicated function
- how to build a path from p or q to root
- how to build a path from root to p
- Naive solution with Timeout and Complicated function
- Post order traversal
- recursive function - Do not understand
- Recursive solution Easy to understand
- Recursive solution with backtracking
- Timeout challenge
Here is the folder to look up problems and solution based on topics I worked on.
I also warn myself not to take risk if I am not ready. The bug I came cross on 236 lowest common ancestor reminds me to work on classical algorithm more carefully, focus on learning backtracking, space analysis, and also think about solving algorithms from as many ideas as possible.
The problem solver is not that I learn how to solve the algorithm in one of ways. The interviewer likes to learn that you can be flexible and be able to handle different solutions and know what to choose and what not to choose.
Be responsible and be a grown-up. That is the reason I like to take the opportunity as a learning process. Do not take too serious to feel frustrated because of failure.
Bugs are my weakness, so serious!
I also warn myself not to take risk if I am not ready. The bug I came cross on 236 lowest common ancestor reminds me to work on classical algorithm more carefully, focus on learning backtracking, space analysis, and also think about solving algorithms from as many ideas as possible.
The problem solver is not that I learn how to solve the algorithm in one of ways. The interviewer likes to learn that you can be flexible and be able to handle different solutions and know what to choose and what not to choose.
Be responsible and be a grown-up. That is the reason I like to take the opportunity as a learning process. Do not take too serious to feel frustrated because of failure.
No comments:
Post a Comment