114.Flatten-Binary-Tree-to-Linked-List
114. Flatten Binary Tree to Linked List
题目地址
https://leetcode.com/problems/flatten-binary-tree-to-linked-list/
题目描述
Given a binary tree, flatten it to a linked list in-place.
For example, given the following tree:
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
\
6代码
Approach #1 Recursion
Time Complexity && Space Complexity: O(N)
Approach #1 Recursion
Approach #2 Iteration
Approach #3 O(1) Iteration
Approach #2 Iterative + Stack
Time Complexity & Space Complexity: O(N)
Last updated
Was this helpful?