There are 3 possible approaches: DP, divide&conquer and greedy. And apparently, DP has O(n^2) complexity, DivideConquer can only be worse. Greedy can ...
分类:
其他好文 时间:
2016-10-24 07:42:05
阅读次数:
234
O(1):constant - the operation doesn't depend on the size of its input, e.g. adding a node to the tail of a linked list where we always maintain a poin ...
分类:
其他好文 时间:
2016-10-17 23:03:46
阅读次数:
159
Given 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). For example,S = "ADOBECOD ...
分类:
编程语言 时间:
2016-10-16 16:25:22
阅读次数:
188
1. 归并排序 归并排序是基于一种被称为“分治”(divide and conquer)的策略。 Sort List Sort a linked list in O(n log n) time using constant space complexity. method 1: merge sort ...
分类:
编程语言 时间:
2016-10-07 07:45:56
阅读次数:
199
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. ...
分类:
其他好文 时间:
2016-10-02 00:24:43
阅读次数:
123
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh ...
分类:
其他好文 时间:
2016-10-01 17:27:20
阅读次数:
251
Given 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). For example,S = "ADOBECOD ...
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity ...
分类:
其他好文 时间:
2016-09-26 14:47:29
阅读次数:
128
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 or ...
分类:
其他好文 时间:
2016-09-22 06:31:31
阅读次数:
145
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 or ...
分类:
其他好文 时间:
2016-09-19 06:42:44
阅读次数:
120