topic109

package
v0.0.0-...-b071cee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

README

109.有序链表转换二叉搜索树

1. 题目描述

给定一个单链表的头节点 head ,其中的元素 按升序排序 ,将其转换为高度平衡的二叉搜索树。

本题中,一个高度平衡二叉树是指一个二叉树 每个节点 的左右两个子树的高度差不超过 1。

示例 1:


输入: head = [-10,-3,0,5,9]
输出: [0,-3,9,-10,null,5]
解释: 一个可能的答案是[0,-3,9,-10,null,5],它表示所示的高度平衡的二叉搜索树。

示例 2:


输入: head = []
输出: []

提示:

  • head 中的节点数在 [0, 2 * 10^4] 范围内
  • -10^5 <= Node.val <= 10^5

标签 二叉搜索树 链表 分治 二叉树

2. 解题

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL