LeetCode p109 Convert Sorted List to Binary Search Tree 题解
1.题目:
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
题意:
输入一个递增的链表,输出它的平衡二叉树。
2.解题思路:
快慢指针找中间,递归。
3.代码
1 |
|
很高兴遇见你~
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
题意:
输入一个递增的链表,输出它的平衡二叉树。
快慢指针找中间,递归。
1 |
|