1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/BiNode(English) [binode-lcci].html

21 lines
936 B
HTML

<p>The data structure&nbsp;<code>TreeNode</code>&nbsp;is used for binary tree, but it can also used to represent a single linked list (where left is null, and right is the next node in the list). Implement a method to convert a binary search tree (implemented with <code>TreeNode</code>) into a single&nbsp;linked list. The values should be kept in order and the operation should be performed in place (that is, on the original data structure).</p>
<p>Return the head node of the linked list after converting.</p>
<p><b>Note:&nbsp;</b>This problem is slightly different from the original one in the book.</p>
<p>&nbsp;</p>
<p><strong>Example: </strong></p>
<pre>
<strong>Input: </strong> [4,2,5,1,3,null,6,0]
<strong>Output: </strong> [0,null,1,null,2,null,3,null,4,null,5,null,6]
</pre>
<p><strong>Note: </strong></p>
<ul>
<li>The number of nodes will not exceed&nbsp;100000.</li>
</ul>