From 7659ee107201cf2a582e5dd8682fa75d375dbe12 Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Wed, 28 Oct 2026 13:45:05 +0800 Subject: [PATCH] =?UTF-8?q?Update=2036.=20=E4=BA=8C=E5=8F=89=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A0=91=E4=B8=8E=E5=8F=8C=E5=90=91=E9=93=BE=E8=A1=A8?= =?UTF-8?q?.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。 --- notes/36. 二叉搜索树与双向链表.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/notes/36. 二叉搜索树与双向链表.md b/notes/36. 二叉搜索树与双向链表.md index 58b61faf..7c474b6f 100644 --- a/notes/36. 二叉搜索树与双向链表.md +++ b/notes/36. 二叉搜索树与双向链表.md @@ -1,6 +1,6 @@ # 36. 二叉搜索树与双向链表 -[NowCoder](https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) +[Leetcode](https://leetcode.cn/problems/er-cha-sou-suo-shu-yu-shuang-xiang-lian-biao-lcof/) ## 题目描述 @@ -11,15 +11,21 @@ ## 解题思路 ```java -private TreeNode pre = null; -private TreeNode head = null; +private Node pre = null; +private Node head = null; -public TreeNode Convert(TreeNode root) { +public Node treeToDoublyList(Node root) { + if (root == null) + return null; + head = null; + pre = null; inOrder(root); + head.left = pre; + pre.right = head; return head; } -private void inOrder(TreeNode node) { +private void inOrder(Node node) { if (node == null) return; inOrder(node.left);