Better Solution: O(KlogK), 转自https://discuss.leetcode.com/topic/50885/simple-java-o-klogk-solution-with-explanation Naive Solution: 就是没有利用每个数组都是sorted ...
分类:
其他好文 时间:
2016-11-28 09:29:26
阅读次数:
183
Implement a stack with min() function, which will return the smallest number in the stack. It should support push, pop and min operation all in O(1) c ...
分类:
其他好文 时间:
2016-11-14 07:50:37
阅读次数:
280
Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n. Note: 1 ≤ k ≤ n ≤ 109. Example: s 类似题目: Lexicograph ...
分类:
其他好文 时间:
2016-11-04 23:06:21
阅读次数:
191
题目: Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it i ...
分类:
其他好文 时间:
2016-11-02 17:17:55
阅读次数:
156
和merge k sorted linked list是一样的,不同就是自己要打一个包建一个类,然后建一个pq 时间复杂度是O(klogn). n = matrix.length ...
分类:
其他好文 时间:
2016-10-24 09:42:13
阅读次数:
257
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla ...
分类:
其他好文 时间:
2016-10-15 13:38:57
阅读次数:
124
感谢算法助教们给了这么一个好题... 题意: 给出n个数组,每个数组有n个元素,我们从每个数组中挑选一个元素,共计n个元素求和,得到共计 $ k^k $ 种sum,求sum中的最小n个值。 思路1代码: 1 #include<cstdio> 2 #include<iostream> 3 #inclu ...
分类:
其他好文 时间:
2016-10-12 19:01:50
阅读次数:
340
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l ...
分类:
其他好文 时间:
2016-09-19 06:44:24
阅读次数:
133
Given an array of integers, find the subarray with smallest sum. Return the sum of the subarray. Notice The subarray should contain one integer at lea ...
分类:
其他好文 时间:
2016-09-12 14:02:29
阅读次数:
152
Smallest Difference Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8463 Accepted: 2324 Description Given a number of distinct decimal digi ...
分类:
其他好文 时间:
2016-09-09 10:20:24
阅读次数:
164