Saturday, May 11, 2019

How I pace myself on Leetcode training?

May 11, 2019


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. 

The solution folder is here


Topics 
  1. BFS
  2. child-parent map
  3. Fix naive solution timeout with complicated function
  4. how to build a path from p or q to root
  5. how to build a path from root to p
  6. Naive solution with Timeout and Complicated function
  7. Post order traversal
  8. recursive function - Do not understand
  9. Recursive solution Easy to understand
  10. Recursive solution with backtracking
  11. Timeout challenge

Here is the folder to look up problems and solution based on topics I worked on. 


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