Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2015-07-08 14:32:36
阅读次数:
92
public class Solution { //卡特兰数,一共有C2n^n-C2n^n-1种组合数 //本题的递归非常经典,需要多看牢记 List res; StringBuilder seq; public List generateParenthesis(int...
分类:
其他好文 时间:
2015-07-08 00:24:55
阅读次数:
110
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public...
分类:
其他好文 时间:
2015-07-08 00:14:36
阅读次数:
152
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ...
分类:
其他好文 时间:
2015-07-07 18:48:56
阅读次数:
99
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
分类:
其他好文 时间:
2015-07-07 16:38:17
阅读次数:
86
Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re...
分类:
其他好文 时间:
2015-07-07 16:17:41
阅读次数:
102
public class Solution { public List res; public StringBuilder seq; public List letterCombinations(String digits) { //本题类似于全排列的变形,全排列的每...
分类:
其他好文 时间:
2015-07-07 14:28:47
阅读次数:
123
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...
分类:
其他好文 时间:
2015-07-07 12:48:06
阅读次数:
128
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...
分类:
其他好文 时间:
2015-07-07 12:22:55
阅读次数:
113
public class Solution { public List> threeSum(int[] nums) { //本题需要对重复数字进行考虑,主要涉及以下几处: //1.外层循环时,需要与前一个数进行比较,如果重复,使用 if 和continue ...
分类:
其他好文 时间:
2015-07-07 00:37:35
阅读次数:
140