07 2014 档案

[leetcode]Climbing Stairs
摘要:Climbing StairsYou are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct way... 阅读全文

posted @ 2014-07-31 23:08 喵星人与汪星人 阅读(187) 评论(0) 推荐(0) 编辑

[leetcode]Longest Substring Without Repeating Characters
摘要:Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ... 阅读全文

posted @ 2014-07-31 22:56 喵星人与汪星人 阅读(200) 评论(0) 推荐(0) 编辑

[leetcode]Longest Common Prefix
摘要:Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.算法思路:思路:貌似木有什么捷径,逐个比较,遇到不同即断开。代码如下: 1 publi... 阅读全文

posted @ 2014-07-31 21:52 喵星人与汪星人 阅读(179) 评论(0) 推荐(0) 编辑

[leetcode]Populating Next Right Pointers in Each Node II
摘要:Populating Next Right Pointers in Each Node IIFollow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any ... 阅读全文

posted @ 2014-07-31 20:40 喵星人与汪星人 阅读(174) 评论(0) 推荐(0) 编辑

[leetcode]Populating Next Right Pointers in Each Node
摘要:Populating Next Right Pointers in Each NodeGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLi... 阅读全文

posted @ 2014-07-31 20:35 喵星人与汪星人 阅读(246) 评论(0) 推荐(0) 编辑

[leetcode]Path Sum II
摘要:Path Sum IIGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tr... 阅读全文

posted @ 2014-07-31 20:29 喵星人与汪星人 阅读(151) 评论(0) 推荐(0) 编辑

[leetcode]Path Sum
摘要:Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the give... 阅读全文

posted @ 2014-07-31 20:27 喵星人与汪星人 阅读(219) 评论(0) 推荐(0) 编辑

[leetcode]Balanced Binary Tree
摘要:Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre... 阅读全文

posted @ 2014-07-31 20:22 喵星人与汪星人 阅读(227) 评论(0) 推荐(0) 编辑

[leetcode]Convert Sorted Array to Binary Search Tree
摘要:Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.算法:根据有序数组,生... 阅读全文

posted @ 2014-07-31 20:19 喵星人与汪星人 阅读(138) 评论(0) 推荐(0) 编辑

[leetcode]Construct Binary Tree from Inorder and Postorder Traversal
摘要:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assu... 阅读全文

posted @ 2014-07-31 20:16 喵星人与汪星人 阅读(227) 评论(0) 推荐(0) 编辑

[leetcode]Construct Binary Tree from Preorder and Inorder Traversal
摘要:Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume... 阅读全文

posted @ 2014-07-31 20:11 喵星人与汪星人 阅读(207) 评论(0) 推荐(0) 编辑

[leetcode]Minimum Depth of Binary Tree
摘要:Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root... 阅读全文

posted @ 2014-07-31 20:06 喵星人与汪星人 阅读(214) 评论(0) 推荐(0) 编辑

[leetcode]Maximum Depth of Binary Tree
摘要:Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ... 阅读全文

posted @ 2014-07-31 20:02 喵星人与汪星人 阅读(128) 评论(0) 推荐(0) 编辑

[leetcode]Same Tree
摘要:Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally ide... 阅读全文

posted @ 2014-07-31 19:56 喵星人与汪星人 阅读(150) 评论(0) 推荐(0) 编辑

[leetcode]Symmetric Tree
摘要:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric... 阅读全文

posted @ 2014-07-31 19:53 喵星人与汪星人 阅读(163) 评论(0) 推荐(0) 编辑

[leetcode]Recover Binary Search Tree
摘要:Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol... 阅读全文

posted @ 2014-07-31 19:47 喵星人与汪星人 阅读(236) 评论(0) 推荐(0) 编辑

[leetcode]Validate Binary Search Tree
摘要:Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre... 阅读全文

posted @ 2014-07-31 19:39 喵星人与汪星人 阅读(188) 评论(0) 推荐(0) 编辑

[leetcode]Pow(x, n)
摘要:Pow(x, n)Implement pow(x,n).算法思路:二分法,没什么好说的,小心点就行;这个题时间比较苛刻。return pow(x,n >> 1) * pow(x,n >> 1) 是过不去的,因此把pow(x,n / 2)求出来先。其实时间复杂度而言,是一样的。【注意】:n的取值范围;... 阅读全文

posted @ 2014-07-25 23:31 喵星人与汪星人 阅读(172) 评论(0) 推荐(0) 编辑

[leetcode]Subsets II
摘要:Subsets IIGiven a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descend... 阅读全文

posted @ 2014-07-25 22:57 喵星人与汪星人 阅读(254) 评论(0) 推荐(0) 编辑

[leetcode]Subsets
摘要:SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must... 阅读全文

posted @ 2014-07-25 22:40 喵星人与汪星人 阅读(236) 评论(0) 推荐(0) 编辑

[leetcode]Insert Interval
摘要:Insert IntervalGiven a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals... 阅读全文

posted @ 2014-07-25 22:16 喵星人与汪星人 阅读(172) 评论(0) 推荐(0) 编辑

[leetcode]Merge Intervals
摘要:Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18]... 阅读全文

posted @ 2014-07-25 20:56 喵星人与汪星人 阅读(193) 评论(0) 推荐(0) 编辑

[leetcode]Valid Palindrome
摘要:Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a pla... 阅读全文

posted @ 2014-07-25 15:47 喵星人与汪星人 阅读(164) 评论(0) 推荐(0) 编辑

[leetcode]Merge Sorted Array
摘要:Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that i... 阅读全文

posted @ 2014-07-24 22:52 喵星人与汪星人 阅读(221) 评论(0) 推荐(0) 编辑

[leetcode]Length of Last Word
摘要:Length of Last WordGiven a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.I... 阅读全文

posted @ 2014-07-24 22:24 喵星人与汪星人 阅读(132) 评论(0) 推荐(0) 编辑

[leetcode]Simplify Path
摘要:Simplify PathGiven an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to sh... 阅读全文

posted @ 2014-07-24 22:03 喵星人与汪星人 阅读(235) 评论(0) 推荐(1) 编辑

[leetcode]Add Binary
摘要:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法思路:模拟二进制加法,跟十进制木有区别,将a,b转置(不转置的话,倒着... 阅读全文

posted @ 2014-07-24 21:08 喵星人与汪星人 阅读(310) 评论(0) 推荐(0) 编辑

[leetcode]Substring with Concatenation of All Words
摘要:Substring with Concatenation of All WordsYou are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices o... 阅读全文

posted @ 2014-07-24 17:28 喵星人与汪星人 阅读(203) 评论(0) 推荐(0) 编辑

[leetcode]Valid Parentheses
摘要:Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos... 阅读全文

posted @ 2014-07-24 16:00 喵星人与汪星人 阅读(148) 评论(0) 推荐(0) 编辑

[leetcode]Reverse Words in a String
摘要:Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click... 阅读全文

posted @ 2014-07-24 00:26 喵星人与汪星人 阅读(160) 评论(0) 推荐(0) 编辑

[leetcode]ZigZag Conversion
摘要:ZigZag ConversionThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern i... 阅读全文

posted @ 2014-07-23 23:40 喵星人与汪星人 阅读(157) 评论(0) 推荐(0) 编辑

[leetcode]Gray Code
摘要:Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the tot... 阅读全文

posted @ 2014-07-23 22:16 喵星人与汪星人 阅读(274) 评论(0) 推荐(0) 编辑

[leetcode]Permutation Sequence
摘要:Permutation SequenceThe set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the fo... 阅读全文

posted @ 2014-07-23 20:32 喵星人与汪星人 阅读(329) 评论(0) 推荐(0) 编辑

[leetcode]Next Permutation
摘要:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen... 阅读全文

posted @ 2014-07-23 18:41 喵星人与汪星人 阅读(262) 评论(0) 推荐(0) 编辑

[leetcode]PermutationsII
摘要:Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the follow... 阅读全文

posted @ 2014-07-23 17:25 喵星人与汪星人 阅读(287) 评论(0) 推荐(0) 编辑

[leetcode]Add Two Numbers
摘要:Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes co... 阅读全文

posted @ 2014-07-23 16:17 喵星人与汪星人 阅读(240) 评论(0) 推荐(0) 编辑

[leetcode]Permutations
摘要:PermutationsGiven a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3]... 阅读全文

posted @ 2014-07-22 16:26 喵星人与汪星人 阅读(209) 评论(0) 推荐(0) 编辑

[leetcode]Combinations
摘要:CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文

posted @ 2014-07-22 15:40 喵星人与汪星人 阅读(277) 评论(0) 推荐(0) 编辑

[leetcode]Triangle
摘要:TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given... 阅读全文

posted @ 2014-07-22 01:41 喵星人与汪星人 阅读(308) 评论(0) 推荐(0) 编辑

[leetcode]Pascal's Triangle II
摘要:Pascal's Triangle IIGiven an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg... 阅读全文

posted @ 2014-07-22 01:01 喵星人与汪星人 阅读(253) 评论(0) 推荐(0) 编辑

[leetcode]Pascal's Triangle
摘要:Pascal's TriangleGivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,... 阅读全文

posted @ 2014-07-22 00:35 喵星人与汪星人 阅读(413) 评论(0) 推荐(0) 编辑

[leetcode]Remove Duplicates from Sorted Array II
摘要:Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =... 阅读全文

posted @ 2014-07-21 23:55 喵星人与汪星人 阅读(242) 评论(0) 推荐(0) 编辑

[leetcode]Remove Duplicates from Sorted Array
摘要:Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文

posted @ 2014-07-21 23:35 喵星人与汪星人 阅读(262) 评论(0) 推荐(0) 编辑

[leetcode]Remove Element
摘要:Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. ... 阅读全文

posted @ 2014-07-21 23:11 喵星人与汪星人 阅读(169) 评论(0) 推荐(0) 编辑

[leetcode]Sort List
摘要:Sort ListSort a linked list inO(nlogn) time using constant space complexity.算法思想:时间复杂度为O(nlogn)的排序算法,有快排、归并、堆排序,快排需要往前遍历,因此不适合单链表,堆排序可以,但是需要O(n)的空间,因此... 阅读全文

posted @ 2014-07-21 22:33 喵星人与汪星人 阅读(258) 评论(0) 推荐(0) 编辑

[leetcode]Reverse Linked List II
摘要:Reverse Linked List IIReverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return... 阅读全文

posted @ 2014-07-21 21:19 喵星人与汪星人 阅读(183) 评论(0) 推荐(0) 编辑

[leetcode]Reverse Nodes in k-Group
摘要:Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a... 阅读全文

posted @ 2014-07-21 20:23 喵星人与汪星人 阅读(307) 评论(0) 推荐(0) 编辑

[leetcode]Reorder List
摘要:Reorder ListGiven a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' val... 阅读全文

posted @ 2014-07-21 15:13 喵星人与汪星人 阅读(277) 评论(0) 推荐(0) 编辑

[leetcode]Insertion Sort List
摘要:Insertion Sort ListSort a linked list using insertion sort.算法思路:最基本的插入排序,时间复杂度O(n*n),空间复杂度O(1)代码: 1 public class Solution { 2 public ListNode inse... 阅读全文

posted @ 2014-07-21 14:50 喵星人与汪星人 阅读(171) 评论(0) 推荐(0) 编辑

[leetcode]Partition List
摘要:Partition ListGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should pres... 阅读全文

posted @ 2014-07-20 17:07 喵星人与汪星人 阅读(172) 评论(0) 推荐(0) 编辑

[leetcode]Remove Duplicates from Sorted List II
摘要:Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or... 阅读全文

posted @ 2014-07-20 15:14 喵星人与汪星人 阅读(186) 评论(0) 推荐(0) 编辑

[leetcode]Remove Duplicates from Sorted List
摘要:Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, r... 阅读全文

posted @ 2014-07-20 14:49 喵星人与汪星人 阅读(191) 评论(0) 推荐(0) 编辑

[leetcode]Merge k Sorted Lists
摘要:Merge k Sorted ListsMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.这道题,第一次刷是过了,第二次同样的代码超时了,看来case是在不断... 阅读全文

posted @ 2014-07-20 01:18 喵星人与汪星人 阅读(280) 评论(0) 推荐(0) 编辑

[leetcode]Merge Two Sorted Lists
摘要:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fir... 阅读全文

posted @ 2014-07-19 18:05 喵星人与汪星人 阅读(292) 评论(0) 推荐(0) 编辑

[leetcode]Rotate List
摘要:Rotate ListGiven a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3-... 阅读全文

posted @ 2014-07-19 17:35 喵星人与汪星人 阅读(167) 评论(0) 推荐(0) 编辑

[leetcode]Swap Nodes in Pairs
摘要:Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2-... 阅读全文

posted @ 2014-07-19 16:32 喵星人与汪星人 阅读(224) 评论(0) 推荐(0) 编辑

[leetcode]Remove Nth Node From End of List
摘要:Remove Nth Node From End of ListGiven a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2... 阅读全文

posted @ 2014-07-19 16:03 喵星人与汪星人 阅读(217) 评论(0) 推荐(0) 编辑

[leetcode]Linked List Cycle II
摘要:Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u... 阅读全文

posted @ 2014-07-19 15:36 喵星人与汪星人 阅读(215) 评论(0) 推荐(0) 编辑

[leetcode]Linked List Cycle
摘要:Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?算法思路1:快慢指针,当两个指针相遇,则表示有环,... 阅读全文

posted @ 2014-07-19 14:59 喵星人与汪星人 阅读(293) 评论(0) 推荐(0) 编辑

[leetcode]Palindrome Number
摘要:Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers b... 阅读全文

posted @ 2014-07-17 23:35 喵星人与汪星人 阅读(213) 评论(0) 推荐(0) 编辑

DFS小结
摘要:这篇博文较长,且理论为主,因为我准备换种风格,以保证大家看的时候不会觉得无聊,看完如果对dfs还是一头雾水,那我也不会请你吃麻辣烫开场:刷了一遍leetcode,发现DFS是个特别强大,且出题率特别高的一个基础算法,第一次接触DFS是树的一个搜索算法,相对而言的是BFS。根据难度与考察频率参考表的建... 阅读全文

posted @ 2014-07-17 23:04 喵星人与汪星人 阅读(448) 评论(0) 推荐(0) 编辑

[leetcode]Reverse Integer
摘要:Reverse IntegerReverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about th... 阅读全文

posted @ 2014-07-17 20:40 喵星人与汪星人 阅读(189) 评论(0) 推荐(0) 编辑

[leetcode]Plus One
摘要:Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant dig... 阅读全文

posted @ 2014-07-17 19:43 喵星人与汪星人 阅读(200) 评论(0) 推荐(0) 编辑

[leetcode]Set Matrix Zeroes
摘要:Set Matrix ZeroesGiven amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight... 阅读全文

posted @ 2014-07-17 16:56 喵星人与汪星人 阅读(199) 评论(0) 推荐(0) 编辑

leetcode中关于树的dfs算法题
摘要:Validate Binary Search TreeRecover Binary Search TreeSymmetric TreeSame TreeMaximum Depth of Binary TreeConstruct Binary Tree from Preorder and Inorde... 阅读全文

posted @ 2014-07-16 21:20 喵星人与汪星人 阅读(367) 评论(0) 推荐(0) 编辑

[leetcode]Count and Say
摘要:Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is r... 阅读全文

posted @ 2014-07-16 20:42 喵星人与汪星人 阅读(395) 评论(0) 推荐(0) 编辑

[leetcode]Palindrome Partitioning
摘要:Palindrome PartitioningGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioni... 阅读全文

posted @ 2014-07-16 00:37 喵星人与汪星人 阅读(206) 评论(0) 推荐(0) 编辑

[leetcode]Letter Combinations of a Phone Number
摘要:Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit ... 阅读全文

posted @ 2014-07-15 22:03 喵星人与汪星人 阅读(253) 评论(0) 推荐(0) 编辑

[leetcode]Restore IP Addresses
摘要:Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"255255... 阅读全文

posted @ 2014-07-15 21:37 喵星人与汪星人 阅读(243) 评论(0) 推荐(0) 编辑

[leetcode]Generate Parentheses
摘要:Generate ParenthesesGivennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a sol... 阅读全文

posted @ 2014-07-15 20:33 喵星人与汪星人 阅读(243) 评论(0) 推荐(0) 编辑

[leetcode]Word Search
摘要:Word SearchGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, wh... 阅读全文

posted @ 2014-07-15 19:20 喵星人与汪星人 阅读(685) 评论(0) 推荐(0) 编辑

[leetcode]N-QueensII
摘要:N-Queens IIFollow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.算法思路:与[leetcode]... 阅读全文

posted @ 2014-07-14 22:30 喵星人与汪星人 阅读(229) 评论(0) 推荐(0) 编辑

[leetcode]N-Queens
摘要:N-QueensThen-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all... 阅读全文

posted @ 2014-07-14 22:09 喵星人与汪星人 阅读(173) 评论(0) 推荐(0) 编辑

[leetcode]Combination Sum
摘要:Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thes... 阅读全文

posted @ 2014-07-14 02:16 喵星人与汪星人 阅读(348) 评论(0) 推荐(0) 编辑

[leetcode]Combination SumII
摘要:Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sum... 阅读全文

posted @ 2014-07-14 02:08 喵星人与汪星人 阅读(491) 评论(0) 推荐(0) 编辑

NSum小结
摘要:本文载自【k sum problem】以及【NSum】有位同僚,对该问题做出了代码的小结,想看吗?戳我戳我。问题陈述:在一个数组,从中找出k个数(每个数不能重复取。数组中同一个值有多个,可以取多个),使得和为零。找出所有这样的组合,要求没有重复项(只要值不同即可,不要求在原数组中的index不同)解... 阅读全文

posted @ 2014-07-13 23:52 喵星人与汪星人 阅读(581) 评论(0) 推荐(0) 编辑

[leetcode]4Sum
摘要:4SumGiven an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum... 阅读全文

posted @ 2014-07-13 22:49 喵星人与汪星人 阅读(543) 评论(0) 推荐(0) 编辑

[leetcode]3Sum Closest
摘要:3Sum ClosestGiven an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three int... 阅读全文

posted @ 2014-07-13 21:19 喵星人与汪星人 阅读(152) 评论(0) 推荐(0) 编辑

[leetcode]3Sum
摘要:3SumGiven an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:El... 阅读全文

posted @ 2014-07-13 20:51 喵星人与汪星人 阅读(578) 评论(0) 推荐(0) 编辑

[leetcode]Two Sum
摘要:Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the... 阅读全文

posted @ 2014-07-13 20:16 喵星人与汪星人 阅读(353) 评论(0) 推荐(0) 编辑