对于二叉搜索树,可以将其转换为双向链表,其中,节点的左子树指针在链表中指向前一个节点,右子树指针在链表中指向后一个节点。

思路:
采用递归思想,对于二叉搜索树,将左、右子树分别转换为双向链表,左子树转换所得链表的头结点即整个树的头结点,左子树转换所得链表的尾节点与根节点相邻;右子树转换所得链表的尾节点即整个树的尾节点,右子树转换所得链表的头结点与根节点相邻。
152847403
代码:

152735920

Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For exa...

阅读全文

Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not ...

阅读全文

Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space...

阅读全文