maxValBox[0] = tree.val
]]>Didn’t know you had this blog, but that’s a great idea!
I’d like to contribute to it when I get some time.
As for the in order traversal above: where are you adding to the node list?
A special note about these types of problems when interviewing at Microsoft: while algorithmically your solution should be recursive, your implementation should be prefixed by: “the problem with the recursive implementation is that it’s only good when you know the depth, otherwise you can easily blow the stack”. This shows you understand the practical difference between writing code in a classroom and in a production environment. If the interviewer then says: “let’s say you don’t need to worry about that”, you proceed with your solution, but twice in my own experience the problem was precisely about whether I would just rush to implement the obvious and well known book solution, or stop to consider the real world implications.
Just a thought.
Good luck.
P.S. Could not post a comment.
]]>