[LinkList/Tree]109. Convert Sorted List to Binary Search Tree

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LinkList/Tree]109. Convert Sorted List to Binary Search Tree相关的知识,希望对你有一定的参考价值。

参考技术A

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

Example:

1.一看之下感觉和108很像,后来发现是linklist,就又不会做了=。=于是在youtube上找到了公瑾讲解
2.这道题考察了linklist和树的操作
3.找linklist的中位数可以用fast/slow指针去找,每次fast走两格,slow走一格,当fast走完的时候slow刚好走到了中间
4.边界条件其实也很难,一定要注意,当没有数和只有一个数的时候是边界条件,直接退出即可,只有linklist有两个数+的时候才开始找中位数做题。

以上是关于[LinkList/Tree]109. Convert Sorted List to Binary Search Tree的主要内容,如果未能解决你的问题,请参考以下文章

109. Convert Sorted List to Binary Search Tree

[LeetCode] 109. Convert Sorted List to Binary Search Tree

109. Convert Sorted List to Binary Search Tree

leetcode 109 Convert Sorted List to Binary Search Tree

java 109.将Sorted List转换为二进制搜索Tree.java

java 109.将Sorted List转换为二进制搜索Tree.java