摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2015-07-07 11:27 ~每天进步一点点~ 阅读(159) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public List> threeSum(int[] nums) { //本题需要对重复数字进行考虑,主要涉及以下几处: //1.外层循环时,需要与前一个数进行比较,如果重复,使用 if 和continue ... 阅读全文
posted @ 2015-07-06 22:56 ~每天进步一点点~ 阅读(183) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public String longestCommonPrefix(String[] strs) { //求公共子序列,公共子序列必须是str[0]的子串,因此本题是将每一个字符串按位和第一个字符串的每一位进行比较 /... 阅读全文
posted @ 2015-07-06 22:03 ~每天进步一点点~ 阅读(109) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int maxArea(int[] height) { /* 题意:二维坐标系里有 n 个点 (i, ai), ai >= 0,从 (i, ai)到(i, 0)划竖线,共有 n 条竖线。 找出两条竖线,使得... 阅读全文
posted @ 2015-07-06 21:15 ~每天进步一点点~ 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2015-07-06 20:41 ~每天进步一点点~ 阅读(134) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public boolean isPalindrome(int x) { //负数不是回文 //主要的突破点是如何获得整数的第n位和后n位(/和%运算结合) if(x=10){//这里面需要考虑整数越界的... 阅读全文
posted @ 2015-07-06 18:55 ~每天进步一点点~ 阅读(108) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int myAtoi(String str) { //此题需要注意的细节很多 //1.对于“ -123”,“ +3231”,需要考虑去除最前的空格,主要利用循环 //2.对于越界情况需要判... 阅读全文
posted @ 2015-07-05 22:56 ~每天进步一点点~ 阅读(154) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int reverse(int x) { //此题需要注意整数越界问题,因此先将res声明为long,注意32位的范围是0x80000000到0x7fffffff long res=0; i... 阅读全文
posted @ 2015-07-04 22:51 ~每天进步一点点~ 阅读(125) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public String convert(String s, int numRows) { //本题通过画图numRows=4和numRows=5可以得到规则,主线路距离是2*numRows-2;辅助行是(numRows-i-1)... 阅读全文
posted @ 2015-07-04 22:26 ~每天进步一点点~ 阅读(134) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public String longestPalindrome(String s) { //本题是动态规划思想,构造一个数组pal[i][j],表示从i到j是否为一个回文, //pal[i][j]=true;if i=... 阅读全文
posted @ 2015-07-04 21:40 ~每天进步一点点~ 阅读(137) 评论(0) 推荐(0) 编辑