https://oj.leetcode.com/problems/container-with-most-water/http://fisherlei.blogspot.com/2013/01/leetcode-container-with-most-water.htmlpublicclassSolution{
publicintmaxArea(int[]height){
//SolutionB:
//returnmaxArea_BruteForce(height);
//SolutionA:
retur..
分类:
其他好文 时间:
2015-01-02 16:15:22
阅读次数:
158
https://oj.leetcode.com/problems/3sum-closest/http://fisherlei.blogspot.com/2013/01/leetcode-3sum-closest-solution.htmlpublicclassSolution{
publicintthreeSumClosest(int[]num,inttarget){
//Inputvalidations
//...
Arrays.sort(num);
intlen=num.length;
intmin..
分类:
其他好文 时间:
2015-01-02 16:14:25
阅读次数:
116
https://oj.leetcode.com/problems/integer-to-roman/http://fisherlei.blogspot.com/2012/12/leetcode-integer-to-roman.htmlpublicclassSolution{
//
//把4,9定义为特殊的字符
//从大到小适配
publicStringintToRoman(intnum){
if(num<1||num>3999)
returnnull;//Inva..
分类:
其他好文 时间:
2015-01-02 16:14:07
阅读次数:
128
https://oj.leetcode.com/problems/roman-to-integer/http://fisherlei.blogspot.com/2012/12/leetcode-roman-to-integer.html//Symbol Value
//I 1
//V 5
//X 10
//L 50
//C 100
//D 500
//M 1,000
publicclassSolution{
publicintromanToInt(Strings){
Map<Character,In..
分类:
其他好文 时间:
2015-01-02 16:13:57
阅读次数:
163
https://oj.leetcode.com/problems/longest-common-prefix/http://fisherlei.blogspot.com/2012/12/leetcode-longest-common-prefix.htmlpublicclassSolution{
publicStringlongestCommonPrefix(String[]strs)
{
//Validations
if(strs==null||strs.length==0)
return"";
if(s..
分类:
其他好文 时间:
2015-01-02 16:13:25
阅读次数:
103
https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/http://fisherlei.blogspot.com/2012/12/leetcode-letter-combinations-of-phone.htmlpublicclassSolution{
publicList<String>letterCombinations(Stringdigits){
if(digits==null)
returnnul..
分类:
其他好文 时间:
2015-01-02 16:13:14
阅读次数:
134
https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/http://fisherlei.blogspot.com/2012/12/leetcode-remove-nth-node-from-end-of.html/**
*Definitionforsingly-linkedlist.
*publicclassListNode{
*intval;
*ListNodenext;
*ListNode(intx){
*val=x;
*nex..
分类:
其他好文 时间:
2015-01-02 16:12:53
阅读次数:
132
https://oj.leetcode.com/problems/generate-parentheses/http://fisherlei.blogspot.com/2012/12/leetcode-generate-parentheses.htmlpublicclassSolution{
publicList<String>generateParenthesis(intn){
//SolutionB:
//returngenerateParenthesis_BruteForce(n);
..
分类:
其他好文 时间:
2015-01-02 16:12:32
阅读次数:
137
https://oj.leetcode.com/problems/valid-parentheses/http://fisherlei.blogspot.com/2013/01/leetcode-valid-parentheses.htmlpublicclassSolution{
publicbooleanisValid(Strings)
{
if(s==null)
returntrue;
Stack<Character>stack=newStack<>();
for(charc:s..
分类:
其他好文 时间:
2015-01-02 16:12:14
阅读次数:
99
https://oj.leetcode.com/problems/3sum/publicclassSolution{
publicList<List<Integer>>threeSum(int[]num){
//SolutionA
//returnthreeSum_Sort(num);
//SolutionB
returnthreeSum_Map(num);
}
////////////////////
//SolutionA:Sort
//
//O(n^2)
privateLi..
分类:
其他好文 时间:
2015-01-02 16:11:46
阅读次数:
119