본문 바로가기

풀어본 Algorithm 문제 정리

[OJ.leetcode] flatten-binary-tree-to-linked-list

https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/


Given a binary tree, flatten it to a linked list in-place.

For example,
Given

         1
        / \
       2   5
      / \   \
     3   4   6

The flattened tree should look like:
   1
    \
     2
      \
       3
        \
         4
          \
           5
            \
             6