Class Solution
java.lang.Object
g0101_0200.s0114_flatten_binary_tree_to_linked_list.Solution
114 - Flatten Binary Tree to Linked List.<p>Medium</p>
<p>Given the <code>root</code> of a binary tree, flatten the tree into a “linked list”:</p>
<ul>
<li>The “linked list” should use the same <code>TreeNode</code> class where the <code>right</code> child pointer points to the next node in the list and the <code>left</code> child pointer is always <code>null</code>.</li>
<li>The “linked list” should be in the same order as a <a href="https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR" target="_top"><strong>pre-order</strong> <strong>traversal</strong></a> of the binary tree.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/14/flaten.jpg" alt="" /></p>
<p><strong>Input:</strong> root = [1,2,5,3,4,null,6]</p>
<p><strong>Output:</strong> [1,null,2,null,3,null,4,null,5,null,6]</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> root = []</p>
<p><strong>Output:</strong> []</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> root = [0]</p>
<p><strong>Output:</strong> [0]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the tree is in the range <code>[0, 2000]</code>.</li>
<li><code>-100 <= Node.val <= 100</code></li>
</ul>
<p><strong>Follow up:</strong> Can you flatten the tree in-place (with <code>O(1)</code> extra space)?</p>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
flatten
-