码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
LeetCode-Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements fro...
分类:其他好文   时间:2015-01-08 09:43:18    阅读次数:169
[LeetCode#109]Convert Sorted List to Binary Search Tree
The problem:Convert Sorted List to Binary Search TreeLink:https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/My analysis:The i...
分类:其他好文   时间:2015-01-08 02:02:08    阅读次数:179
[LeetCode#108]Convert Sorted Array to Binary Search Tree
The problem:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.My analysis:The recursion is the best way...
分类:其他好文   时间:2015-01-08 00:49:30    阅读次数:265
leetcode----------------Median of Two Sorted Arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 分析 这是一道非常经典的题。这题更通用的形式是,给定两个已经排序...
分类:其他好文   时间:2015-01-07 23:39:15    阅读次数:345
LeetCode Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:其他好文   时间:2015-01-07 23:25:52    阅读次数:112
leetcode 4 Median of Two Sorted Arrays
对于两个数组的折半查找public class Solution { public double findMedianSortedArrays(int A[], int B[]) { int m = A.length, n = B.length; if (n == ...
分类:其他好文   时间:2015-01-07 22:00:34    阅读次数:183
LeetCode Solutions : Find Minimum in Rotated Sorted Array
【算法思路】利用折半查找的思路去查找这个最小元素 【编程步骤】 * 1. 如果数组num只有一个元素,则所求的最小的元素就是它了; * 2. 若left到right位置的元素严格递增,则最小的元素为num[left],如左图 否则,如右图,利用折半查找,若left到mid递增有序,则最小元素必出现在右边部分:mid+1到right; 若mid到right递增有序,则最小元素出现在左边部分:left到mid; while(left<right){ if(num[left]<num...
分类:其他好文   时间:2015-01-07 16:55:49    阅读次数:171
[LeetCode#23]Merge k Sorted Lists
The problem:Sort a linked list inO(nlogn) time using constant space complexity.My analysis:The is problem could be elegantly solved by using merge.The...
分类:其他好文   时间:2015-01-07 01:50:28    阅读次数:112
LeetCode Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret...
分类:其他好文   时间:2015-01-07 00:23:00    阅读次数:245
[LeetCode]23.Merge k Sorted Lists
【题目】 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 【分析】 无 【代码】 /********************************* * 日期:2015-01-06 * 作者:SJF0115 * 题目:...
分类:其他好文   时间:2015-01-06 23:10:50    阅读次数:202
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!