码迷,mamicode.com
首页 >  
搜索关键字:complexity    ( 1097个结果
Search for a Range
题目 Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target i...
分类:其他好文   时间:2014-06-15 16:53:32    阅读次数:177
[Leetcode] Sort List
Question:Sort a linked list inO(nlogn) time using constant space complexity.Solution:Merge sort.找到链表的中间的那个ListNode. 1 /** 2 * Definition for singly-l....
分类:其他好文   时间:2014-06-12 17:59:34    阅读次数:285
[Leetcode] Merge k Sorted Lists
Question: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution: Find the smallest list-head first....
分类:其他好文   时间:2014-06-10 19:51:30    阅读次数:278
Leetcode: Container With Most Water
The most strait forward approach is calculating all the possible areas and keep the max one as the result. This approach needs O(n*n) time complexity,...
分类:其他好文   时间:2014-06-10 16:11:31    阅读次数:184
【Leetcode】Sort List
Sort a linked list inO(nlogn) time using constant space complexity.单向链表排序O(nlogn),Mergesort可以实现。 1 /** 2 * Definition for singly-linked list. 3 * st.....
分类:其他好文   时间:2014-06-10 00:44:11    阅读次数:329
[LeetCode] Sort List
Sort a linked list in O(n log n) time using constant space complexity.一谈到时间复杂度O(nlogn),立即联想到以下3种排序方法:1.归并排序(基于分治):时间复杂度O(nlogn),归并排序的最好、平均、最坏时间复杂度没有差别...
分类:其他好文   时间:2014-06-09 20:37:31    阅读次数:244
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
Algorithm | Binary Search
1. 普通的二分查找2. 查找最左边的值3. 查找最右边的值Worst case performance: O(log n)Best case performance: O(1)Average case performance: O(log n)Worst case space complexity...
分类:其他好文   时间:2014-06-07 11:19:48    阅读次数:248
Sort List
Sort a linked list inO(nlogn) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * L...
分类:其他好文   时间:2014-06-06 20:01:30    阅读次数:333
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!