题目:An image is represented by a binary matrix with0as a white pixel and1as a black pixel. The black pixels are connected, i.e., there is only one blac...
分类:
其他好文 时间:
2015-12-16 09:25:18
阅读次数:
956
题目传送门题意:训练指南P189分析:完全参考书上的思路,k^k的表弄成有序表:表1:A1 + B1 using namespace std;const int N = 750 + 5;int a[N][N];int n;struct P { int v, id; P() {} P(int v, i...
分类:
其他好文 时间:
2015-12-07 20:27:38
阅读次数:
155
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can...
分类:
其他好文 时间:
2015-12-06 11:20:07
阅读次数:
183
B. More Cowbell题意:给定N表示铃铛的个数,和k表示箱子的个数,牛铃铛要放在箱子里运输,要求每个箱子放1个或者2个牛铃铛,且每个箱子都要放铃铛,箱子的大小相等,老板为了省钱,希望箱子越小越好(smallest),求满足条件的箱子的尺寸。给定的n个铃铛的尺寸依次从小到大。样例:6 41 ...
分类:
其他好文 时间:
2015-12-03 23:16:42
阅读次数:
186
11997 - K Smallest SumsYou’re given k arrays, each array has k integers. There are kk ways to pick exactly one element in eacharray and calculate ...
分类:
其他好文 时间:
2015-12-02 14:16:53
阅读次数:
153
用的dfs,但是感觉这个方法应该不是最优的,否则这个题目不应该是hardpublic class Solution { int up = Integer.MAX_VALUE; int low = Integer.MIN_VALUE; int left = Integer.MAX_V...
分类:
其他好文 时间:
2015-12-01 08:25:51
阅读次数:
277
Prime power triplesThe smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly ...
分类:
其他好文 时间:
2015-11-27 21:37:09
阅读次数:
201
public class Solution { TreeNode result = new TreeNode(0); public int kthSmallest(TreeNode root, int k) { helper(root, k); return ...
分类:
其他好文 时间:
2015-11-27 17:32:33
阅读次数:
111
题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t...
分类:
其他好文 时间:
2015-11-27 00:42:42
阅读次数:
171
Minimum SubarrayGiven an array of integers, find the subarray with smallest sum.Return the sum of the subarray.For [1, -1, -2, 1], return -3NoteThe su...
分类:
其他好文 时间:
2015-11-26 06:55:47
阅读次数:
170