描述: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2...
分类:
其他好文 时间:
2014-07-16 19:29:31
阅读次数:
166
1.枚举法(超时) 1 public class Solution { 2 public int largestRectangleArea(int[] height) { 3 int max=-1; 4 for(int i=0;i=0&&height[k] s...
分类:
其他好文 时间:
2014-07-14 08:22:17
阅读次数:
373
There is another solution for customizing the appearance of the preferences.Design a normal XML layout with buttons or whatever you want to add to the...
分类:
其他好文 时间:
2014-07-14 00:47:37
阅读次数:
306
#platform=x86, AMD64, or Intel EM64T#version=DEVEL# Firewall configuration,关闭防火墙firewall --disabled# Install OS instead of upgrade,每次安装均为全新安装install# ...
分类:
其他好文 时间:
2014-07-13 23:02:34
阅读次数:
318
N皇后问题,经典中的经典。 第一遍的时候,只有点思路,但是想不清楚,看了别人的代码。 方法一(Java): public class Solution { int[] row; int[] col; ArrayList res; int N; public vo...
分类:
其他好文 时间:
2014-07-13 22:21:25
阅读次数:
233
1.从外围搜索O,深度搜索出现了Line 35: java.lang.StackOverflowErrorLast executed input:["OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 1 public class Solution { 2...
分类:
其他好文 时间:
2014-07-13 22:12:53
阅读次数:
254
1 public class Solution { 2 public String get(String a,String b) 3 { 4 5 if(a==""||b=="") return ""; 6 int len1=a.le...
分类:
其他好文 时间:
2014-07-13 22:05:47
阅读次数:
238
public class Solution { public int longestConsecutive(int[] num) { HashSet hash=new HashSet(); int max=1; for(int n:num) ...
分类:
其他好文 时间:
2014-07-13 21:52:58
阅读次数:
244
重新学习一遍,看到了这个问题:
描述一个运行时间为O(nlgn)的算法,使之能在给定一个由n个整数构成的集合S和另一个整数 X 时,判断出S中是否存在有两个其和刚好等于 X 的元素。
Solution:
(1)->对整个集合进行排序,可以用快排(含有小文件策略、三者取中策略),时间复杂度O(nlogn),形成一个数组A[n]。
->设定两个下标pBegin和pEnd,分别指向数组...
分类:
其他好文 时间:
2014-07-13 15:46:55
阅读次数:
197
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
public class Solution {
public String addBinary(String a, String b) {
...
分类:
其他好文 时间:
2014-07-12 19:42:26
阅读次数:
168