Introduction
It is such great learning experience to be an interviewer. I had chance to learn from the peer to solve the algorithm called Find minimum path sum from root node to leaf node in tree. I just could not believe that he wrote so clear in the analysis based on breadth first search using a queue. I also like to learn Python from 30 minutes interview, I just copied what he wrote on the paper, and then asked a few questions later on.
Code review
The peer came out the idea to prune the algorithm, if there is a minimum path sum, then it can be used to prune the path by checking current path's sum value.
It is long time for me to think breadth first search using Python, I had chance to learn how to write Python queue. Basically in Python there is no queue class, we have to specify to insert in the front using insert function, and then pop function from the end.
Here is the python code.
No comments:
Post a Comment