My Blog List

[Leetcode Solution] Flatten Binary Tree to Linked List

Analysis

  • A recursive out-of-place algorithm comes out
  • A grace in-place algorithm can be found here

Note

  • Define a return type as reference, then the return value could be used as a left-value
  • In most case the recursion method may not be a in-place algorithm because the depth of recursion is usually in proportion to the input size. Thus the space used in store the stack is not constant

Code


No comments:

Post a Comment

Enter you comment