码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
LeetCode: Convert Sorted Array to Binary Search Tree [108]
【题目】 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 【题意】 给定一个已排序的数组(不存在重复元素),将它转换成一棵平衡二叉搜索树。 【思路】 由于平衡二叉树要求左右子树的高度差绝对值相遇等于1,也就是说左右子树尽可能包含相同数目节点。 则使用二分法来解本题即可。...
分类:其他好文   时间:2014-06-20 11:03:31    阅读次数:246
leetcode--Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def...
分类:其他好文   时间:2014-06-11 22:56:31    阅读次数:257
leetcode--Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN...
分类:其他好文   时间:2014-06-11 21:58:10    阅读次数:300
[leetcode]Merge k Sorted Lists @ Python
原题地址:https://oj.leetcode.com/problems/merge-k-sorted-lists/题意:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its com...
分类:编程语言   时间:2014-06-11 21:57:07    阅读次数:399
[leetcode]Search Insert Position @ Python
原题地址:https://oj.leetcode.com/problems/search-insert-position/题意:Given a sorted array and a target value, return the index if the target is found. If n...
分类:编程语言   时间:2014-06-11 11:28:40    阅读次数:349
leetcode--Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.public class Solution { /** Convert th...
分类:其他好文   时间:2014-06-10 00:22:44    阅读次数:259
[LeetCode] Remove Duplicates from Sorted Array [19]
题目...For example,Given input array A = [1,1,2],Your function should return length = 2, and A is now [1,2]. 解题思路, 移除数组中的重复元素,并返回新数组的长度。 这个题目应该算是简单的题目。使用两个变量就可以。具体的看代码 代码实现......
分类:其他好文   时间:2014-06-08 03:54:22    阅读次数:279
leetcode--Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t...
分类:其他好文   时间:2014-06-08 02:05:43    阅读次数:311
leetcode--Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to...
分类:其他好文   时间:2014-06-08 01:19:29    阅读次数:320
LeetCode: Convert Sorted List to Binary Search Tree [109]
【题目】 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 【题意】 将一个有序链表转换成平衡二叉树 【思路】 思路跟Convert Sorted Array to Binary Search Tree完全一样...
分类:其他好文   时间:2014-06-07 16:20:05    阅读次数:287
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!