public class Solution { public int maxArea(int[] height) { /* 题意:二维坐标系里有 n 个点 (i, ai), ai >= 0,从 (i, ai)到(i, 0)划竖线,共有 n 条竖线。 找出两条竖线,使得...
分类:
其他好文 时间:
2015-07-06 23:00:48
阅读次数:
111
public class Solution { public int reverse(int x) { //此题需要注意整数越界问题,因此先将res声明为long,注意32位的范围是0x80000000到0x7fffffff long res=0; i...
分类:
其他好文 时间:
2015-07-05 00:43:42
阅读次数:
157
public class Solution { public String convert(String s, int numRows) { //本题通过画图numRows=4和numRows=5可以得到规则,主线路距离是2*numRows-2;辅助行是(numRows-i-1)...
分类:
其他好文 时间:
2015-07-04 23:24:18
阅读次数:
149
public class Solution { public String longestPalindrome(String s) { //本题是动态规划思想,构造一个数组pal[i][j],表示从i到j是否为一个回文, //pal[i][j]=true;if i=...
分类:
其他好文 时间:
2015-07-04 22:14:37
阅读次数:
236
双指针思路,循环时,声明一个变量保存范围起始的下标注意:如何在数组只有一个元素,还有遍历到最后一个元素的时候,去更新结果集。public class Solution { public List summaryRanges(int[] nums) { List res=new A...
分类:
其他好文 时间:
2015-06-29 00:16:27
阅读次数:
113
纵向扫描:对所有串,从字符串第0位开始比较,全部相等则继续比较第1,2...n位,直到发生不全部相等的情况,则得出最长公共前缀串。string longestCommonPrefix(vector& strs) { string prefix=""; if(strs.size()==0)...
分类:
其他好文 时间:
2015-05-30 00:26:07
阅读次数:
149
Description:Count the number of prime numbers less than a non-negative number,npublic class Solution { public int countPrimes(int n) { if(n(...
分类:
其他好文 时间:
2015-04-30 23:05:35
阅读次数:
135
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public...
分类:
其他好文 时间:
2015-04-30 23:04:59
阅读次数:
152
191.For example, the 32-bit integer ’11' has binary representation00000000000000000000000000001011, so the function should return 3.Java codeint hammi...
分类:
其他好文 时间:
2015-03-15 22:52:06
阅读次数:
123
源自于LeedCode上的一道实现正则表达式的题目,不过题目对正则匹配的规则有所简化。具体如下: 要求字符串str完全匹配模式pattern,例如: str:abcs pattern:.* √ str:abcabc pattern:abc 要求完全匹配 × 若完全匹配,返回true,否则返回fals...
分类:
其他好文 时间:
2015-01-30 17:13:32
阅读次数:
384