随笔分类 -  dfs

上一页 1 2

[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]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) 编辑

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

posted @ 2014-07-17 23:04 喵星人与汪星人 阅读(448) 评论(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) 编辑

上一页 1 2