Solution 1: TreeMap, Time complexity: O(NlogN) 像这种在一个集合里面寻找有没有比某个数小的数,一般要么treeMap要么treeSet。Interval的题经常需要用treeMap, Data Stream as Disjoint Intervals 就 ...
分类:
其他好文 时间:
2016-12-07 07:45:00
阅读次数:
208
For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. If the target number ...
分类:
其他好文 时间:
2016-12-04 00:46:50
阅读次数:
200
Time Complexity will be O(n) because the "start" and "end" points will only move from left to right once. Sliding Window: Use a count to denote the di ...
分类:
其他好文 时间:
2016-12-03 15:20:38
阅读次数:
171
Sort a linked list in O(n log n) time using constant space complexity. Have you met this question in a real interview? Yes Sort a linked list in O(n l ...
分类:
编程语言 时间:
2016-12-03 02:10:57
阅读次数:
466
refer to https://discuss.leetcode.com/topic/59293/java-easiest-solution-o-logn-with-explanation Time Complexity: O(log n) update and record head in ea ...
分类:
其他好文 时间:
2016-11-30 07:51:26
阅读次数:
197
Time Complexity: O(N) The depth of the directory/file is calculated by counting how many "\t"s are there.The time complexity is O(n) because each subs ...
分类:
其他好文 时间:
2016-11-30 07:47:50
阅读次数:
187
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 sho... ...
分类:
其他好文 时间:
2016-11-26 14:54:10
阅读次数:
223
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. Credits:Special thanks t ...
分类:
其他好文 时间:
2016-11-25 09:19:57
阅读次数:
138
DP 解法, Time Complexity: O(N^2) sort based on width or height, anyone is ok. After the sorting, for each envelope, those envelopes which can fit into t ...
分类:
其他好文 时间:
2016-11-25 07:33:38
阅读次数:
179
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 此题是求阶乘后面零的个数。 ...
分类:
其他好文 时间:
2016-11-20 10:54:28
阅读次数:
120