Tuesday, October 24, 2017

Leetcode: binary tree upside down (II)

Oct. 24, 2017

Introduction


It only takes around 20 minutes to read a recursive solution on the panel of Leetcode discussion. I read the solution this morning around 3:00 am. Now it is 5:43 am, I got up and started to work on my computer and blog this algorithm.

Code study 


It is better for me to choose one of discussion, and check in the code, and then plan to write C# solution later. 

Here is the discussion link.

Analysis 


Most important is to read yfcheng's analysis. Plan to spend 20 minutes to read and also review the drawings. And then I will write down my own words, and make a drawing as well.

Java code 



Recursive solution in Java code:

Iterative solution in Java code:


Actionable Item


I finished the blog at 6:00 AM, only 15 minutes. Will come back to work on the algorithm based on the discussion. 

No comments:

Post a Comment