码迷,mamicode.com
首页 >  
搜索关键字:complexity    ( 1097个结果
[leetcode]Minimum Window Substring
Minimum Window SubstringGiven a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Fo...
分类:Windows程序   时间:2014-08-15 17:43:39    阅读次数:230
【Leetcode长征系列】Single Number II
原题: Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it withou...
分类:其他好文   时间:2014-08-15 14:46:48    阅读次数:207
【Leetcode长征系列】Merge k Sorted Lists
原题: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路:两条两条地合并。时间复杂度为O(n),n为所有链表节点和。 代码: /** * Definition for singly-linked list. * struct List...
分类:其他好文   时间:2014-08-14 20:52:09    阅读次数:275
Leetcode--Sort List
Problem Description: Sort a linked list in O(n log n) time using constant space complexity. 分析:对链表进行排序,思考排序算法时间复杂度为O(nlogn)的只有归并,快排和堆排序,应用到链表上的归并比较合适,这里利用快慢指针找到链表的中间节点,然后分别对两边递归归并排好序后将两边归并即可得到最终...
分类:其他好文   时间:2014-08-13 22:25:57    阅读次数:234
LeetCode:Sort List
Problem:       Sort a linked list in O(n log n) time using constant space complexity. 解题思路:     首先,时间复杂度能达到O(nlgn)的排序算法,常见的有3种:堆排序、归并排序和快速排序, 而对于链表,用堆排序显然不太可能,所以,我们可用归并或者是快排.由于合并...
分类:其他好文   时间:2014-08-12 00:45:13    阅读次数:217
Time, Delays, and Deferred Work <LDD3> 学习笔记 + jiffies.h 分析
Time, Delays, and Deferred Work  Dealing with time involves the following tasks, in order of increasing complexity: ? Measuring time lapses and comparing times ? Knowing the cur...
分类:其他好文   时间:2014-08-12 00:41:13    阅读次数:484
[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)). public class Solution { ...
分类:其他好文   时间:2014-08-11 15:14:12    阅读次数:188
Given a tree, find the node with the minimum sum of distances to other nodes
O(n) complexity, have a traversal for the tree. Get the information of all children, then traverse the tree again.  #include #include #include #include using namespace std; class Node { pub...
分类:其他好文   时间:2014-08-10 13:00:30    阅读次数:238
Sort List
Sort a linked list in O(n log n) time using constant space complexity.思路:题目要求O(n log n)的时间复杂度以及常空间复杂度,因此,使用归并排序策略。 1 class Solution { 2 public: 3 ...
分类:其他好文   时间:2014-08-09 23:13:19    阅读次数:284
[leetcode]Search for a Range
Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ...
分类:其他好文   时间:2014-08-09 18:18:28    阅读次数:214
1097条   上一页 1 ... 97 98 99 100 101 ... 110 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!