https://oj.leetcode.com/problems/palindrome-number/http://fisherlei.blogspot.com/2012/12/leetcode-palindrome-number.htmlpublicclassSolution{
publicbooleanisPalindrome(intx){
//Assume
//Negativenumberscannotbepalindrome
if(x<0)
returnfalse;
//Noextrasp..
分类:
其他 时间:
2015-01-02 16:12:39
收藏:
0 评论:
0 赞:
0 阅读:
294
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:12:20
收藏:
0 评论:
0 赞:
0 阅读:
204
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:12:09
收藏:
0 评论:
0 赞:
0 阅读:
219
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:11:49
收藏:
0 评论:
0 赞:
0 阅读:
216
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:11:39
收藏:
0 评论:
0 赞:
0 阅读:
216
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:19
收藏:
0 评论:
0 赞:
0 阅读:
201
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:11:09
收藏:
0 评论:
0 赞:
0 阅读:
314
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:10:59
收藏:
0 评论:
0 赞:
0 阅读:
184
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:10:49
收藏:
0 评论:
0 赞:
0 阅读:
362
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:10:39
收藏:
0 评论:
0 赞:
0 阅读:
251
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:10:29
收藏:
0 评论:
0 赞:
0 阅读:
271
https://oj.leetcode.com/problems/merge-k-sorted-lists/http://fisherlei.blogspot.com/2012/12/leetcode-merge-k-sorted-lists.html/**
*Definitionforsingly-linkedlist.
*publicclassListNode{
*intval;
*ListNodenext;
*ListNode(intx){
*val=x;
*next=null;
*}
*}
*/
pu..
分类:
其他 时间:
2015-01-02 16:10:19
收藏:
0 评论:
0 赞:
0 阅读:
274
https://oj.leetcode.com/problems/swap-nodes-in-pairs/http://fisherlei.blogspot.com/2013/01/leetcode-swap-nodes-in-pairs.html/**
*Definitionforsingly-linkedlist.
*publicclassListNode{
*intval;
*ListNodenext;
*ListNode(intx){
*val=x;
*next=null;
*}
*}
*/
publ..
分类:
其他 时间:
2015-01-02 16:10:09
收藏:
0 评论:
0 赞:
0 阅读:
274
https://oj.leetcode.com/problems/reverse-nodes-in-k-group/http://fisherlei.blogspot.com/2012/12/leetcode-reverse-nodes-in-k-group.html/**
*Definitionforsingly-linkedlist.
*publicclassListNode{
*intval;
*ListNodenext;
*ListNode(intx){
*val=x;
*next=null;
*}
..
分类:
其他 时间:
2015-01-02 16:09:49
收藏:
0 评论:
0 赞:
0 阅读:
286
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/http://fisherlei.blogspot.com/2012/12/leetcode-remove-duplicates-from-sorted.htmlpublicclassSolution{
publicintremoveDuplicates(int[]A){
if(A==null||A.length==0)
return0;//Invalidinput.
..
分类:
其他 时间:
2015-01-02 16:09:39
收藏:
0 评论:
0 赞:
0 阅读:
245
https://oj.leetcode.com/problems/remove-element/http://fisherlei.blogspot.com/2012/12/leetcode-remove-element.htmlpublicclassSolution{
publicintremoveElement(int[]A,intelem){
//Theordercanbechanged.
//Use2pointers.
//Onetoiteratethearray,
//Onetocopythelas..
分类:
其他 时间:
2015-01-02 16:09:29
收藏:
0 评论:
0 赞:
0 阅读:
248
https://oj.leetcode.com/problems/implement-strstr/http://fisherlei.blogspot.com/2012/12/leetcode-implement-strstr.htmlpublicclassSolution{
publicintstrStr(Stringhaystack,Stringneedle){
//遍历haystack,对每一个字符,匹配needle
if(haystack==null||needle==nu..
分类:
其他 时间:
2015-01-02 16:09:09
收藏:
0 评论:
0 赞:
0 阅读:
263
https://oj.leetcode.com/problems/next-permutation/http://fisherlei.blogspot.com/2012/12/leetcode-next-permutation.htmlpublicclassSolution{
publicvoidnextPermutation(int[]num){
//SolutionB
nextPermutation_Math(num);
//SolutionA
//nextPermutation_AllPerms(..
分类:
其他 时间:
2015-01-02 16:08:20
收藏:
0 评论:
0 赞:
0 阅读:
338
R1:HQ#shrunBuildingconfiguration...Currentconfiguration:2433bytes!version12.4servicetimestampsdebugdatetimemsecservicetimestampslogdatetimemsecnoservicepassword-encryption!hostnameHQ!boot-start-markerboot-end-marker!enablesecret5$1$Y6K/$lir0fGeg6iG58JyQ7A0..
分类:
其他 时间:
2015-01-02 16:08:00
收藏:
0 评论:
0 赞:
0 阅读:
286
程序开发中,我们不可能把所有的功能一次全部实现,那么我们就应该留一些接口出来,让其他的功能以插件的形式添加到我们的程序中,这样我们的程序不用做任何更改就可以添加很多新的功能了。我们常用的软件如excel、photoshop等,都有这些功能,那么该如何实现呢?本文通过一个简单的例子实现。...
分类:
其他 时间:
2015-01-02 16:06:42
收藏:
0 评论:
0 赞:
0 阅读:
212