Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list.

Let's take the following BST as an example, it may help you understand the problem better:

We want to transform this BST into a circular doubly linked list. Each node in a doubly linked list has a predecessor and successor. For a circular doubly linked list, the predecessor of the first element is the last element, and the successor of the last element is the first element.

The figure below shows the circular doubly linked list for the BST above. The "head" symbol means the node it points to is the smallest element of the linked list.

Specifically, we want to do the transformation in place. After the transformation, the left pointer of the tree node should point to its predecessor, and the right pointer should point to its successor. We should return the pointer to the first element of the linked list.

The figure below shows the transformed BST. The solid line indicates the successor relationship, while the dashed line means the predecessor relationship.

[leetcode]426. Convert Binary Search Tree to Sorted Doubly Linked List二叉搜索树转有序双向链表的更多相关文章

  1. LeetCode 426. Convert Binary Search Tree to Sorted Doubly Linked List

    原题链接在这里:https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/ 题目: C ...

  2. 【LeetCode】426. Convert Binary Search Tree to Sorted Doubly Linked List 解题报告 (C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 迭代 日期 题目地址:https://leetc ...

  3. 426. Convert Binary Search Tree to Sorted Doubly Linked List把bst变成双向链表

    [抄题]: Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right po ...

  4. [LC] 426. Convert Binary Search Tree to Sorted Doubly Linked List

    Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers ...

  5. [LeetCode] Convert Binary Search Tree to Sorted Doubly Linked List 将二叉搜索树转为有序双向链表

    Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers ...

  6. LeetCode426.Convert Binary Search Tree to Sorted Doubly Linked List

    题目 Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right point ...

  7. [LeetCode] 272. Closest Binary Search Tree Value II 最近的二叉搜索树的值 II

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...

  8. [LeetCode#272] Closest Binary Search Tree Value II

    Problem: Given a non-empty binary search tree and a target value, find k values in the BST that are ...

  9. [LeetCode] Trim a Binary Search Tree 修剪一棵二叉搜索树

    Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that a ...

随机推荐

  1. PLSQL导出表结构

    1:进行plsql后选怎Tools--------->Exports User Ojbects------------->选中需要导出的table,squence,view,type,fu ...

  2. 【Python编程:从入门到实践】chapter4 操作列表

    chapter4 操作列表 4.1 遍历整个列表 magicians=['alice','david','carolina'] for magician in magicians: print(mag ...

  3. ETL,BPM与ESB三者的一些感悟

    1.ETL: 数据层之间,主要在数据库层面上进行数据抽取过程------数据库层 2.ESB 异构系统之间通过总线技术,实现系统交互---------------系统通信层 3.BPM 自动化流程处理 ...

  4. php parse_str() 函数

    php parse_str() 函数把查询字符串解析到变量中,主要用于页面之间传值(参数).本文章向码农介绍php parse_str() 函数的使用方法,感兴趣的码农可以参考一下. 定义和用法 pa ...

  5. sql server查看表占用索引空间(小技巧)

    选择表右键—属性—存储—索引空间

  6. Java调用Bat

    import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.Input ...

  7. Code First use dotConnect for MySQL

    http://www.dotblogs.com.tw/yc421206/archive/2014/03/24/144507.aspx dotConnect for MySQL 是一家強大的 3rd C ...

  8. spring boot 整合 (全)

    参考: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples

  9. maven错误

    maven-enforcer-plugin (goal "enforce") is ignored by m2e. Plugin execution not covered by ...

  10. html的基本数据类型(数字,字符串, 列表, 字典)

    基本数据类型 1. 数字 a = 18 ; 2. 字符串 a = 'alex'a.chartAt(索引位置)a.substring(起始位置, 借宿位置)a.length 获取当前字符串长度a.tri ...