摘要:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:根据递增序列,求平衡二叉查找树,根据平衡二叉查找树的性质,其左右都是二叉查找树,用递归可以比较轻... 阅读全文
摘要:
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
摘要:
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
摘要:
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
摘要:
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:找到链表的中点,作为根,前端作为左子树,后端作为右子树,并对前后做递归操... 阅读全文
摘要:
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?首先指... 阅读全文
摘要:
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?解题思路:突发奇想,脑洞大开。回路,自然是走到已经走过的地方,如何知道这个地方已经走... 阅读全文
摘要:
Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文