68: Flatten binary tree
Given a binary tree
, return a flattened tree
Note: do it
in-place
, i.e. update the original tree rather than creating a new one
Example 1
Input: 1
/ \
2 3
Output: 1
/ \
null 2
/ \
null 3
Example 2
Input: 1
/ \
2 5
/ \
3 4
Output: 1 -> 2 -> 3 -> 4 -> 5
Helpful article