![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dfs
文章平均质量分 82
_xiaoyuer
世界一定有光
展开
-
HDU - 1728 - 逃离迷宫(dfs)
逃离迷宫Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22734 Accepted Submission(s): 5546Problem Description 给定一个m × n (m行, n列)原创 2016-07-27 11:25:23 · 282 阅读 · 0 评论 -
LeetCode - 108/109. Convert Sorted Array/List to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.dfs解决,每次找到数组中间的点,构建子树。时间复杂度O(n),空间复杂度O(n)/** * Definition for a binary tree node. * struct原创 2017-07-25 13:18:58 · 185 阅读 · 0 评论 -
LeetCode - 200 - Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu原创 2017-07-25 14:06:42 · 191 阅读 · 0 评论 -
LeetCode - 207/210 - Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as原创 2017-07-25 17:15:38 · 171 阅读 · 0 评论 -
LeetCode - 417 - Pacific Atlantic Water Flow
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" tou原创 2017-08-04 14:29:36 · 204 阅读 · 0 评论 -
LeetCode - 46 - Permutations
Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1原创 2017-08-04 14:29:44 · 282 阅读 · 0 评论 -
LeetCode - 22 - Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())原创 2017-08-11 17:16:07 · 185 阅读 · 0 评论 -
LeetCode - 450 - Delete Node in a BST
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be divided i原创 2017-07-28 17:45:27 · 266 阅读 · 0 评论 -
LeetCode - 623 - Add One Row to Tree
Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 1.The adding rule is: given a positive in原创 2017-07-28 17:45:38 · 227 阅读 · 0 评论 -
LeetCode - 501 - Find Mode in Binary Search Tree
Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a node c原创 2017-07-28 17:45:48 · 296 阅读 · 0 评论 -
LeetCode - 222 - Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled,原创 2017-07-28 17:46:01 · 197 阅读 · 0 评论 -
LeetCode - 1078(记忆化搜索) - FatMouse and Cheese
FatMouse and CheeseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10550 Accepted Submission(s): 4452Problem DescriptionFatMo原创 2017-07-24 17:09:06 · 267 阅读 · 0 评论 -
LeetCode - 131 - Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return[ ["aa","b"],原创 2017-08-08 18:21:50 · 135 阅读 · 0 评论 -
HDU - 1010 - Tempter of the Bone(dfs)
Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 106147 Accepted Submission(s): 28867Problem DescriptionThe原创 2016-07-25 11:26:42 · 221 阅读 · 0 评论 -
Codeforces - 277.5 (Div. 2)C - Given Length and Sum of Digits...(模拟 or dfs)
C. Given Length and Sum of Digits...time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a positive integ原创 2016-07-22 14:47:42 · 269 阅读 · 0 评论 -
POJ - 3009 - Curling 2.0(dfs)
Curling 2.0Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 17681 Accepted: 7268DescriptionOn Planet MM-21, after their Olympic games this year, curlin原创 2016-07-20 10:19:52 · 256 阅读 · 0 评论 -
POJ - 1016 - Prime Ring Problem(dfs)
Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 43391 Accepted Submission(s): 19262Problem DescriptionA rin原创 2016-09-11 13:52:08 · 202 阅读 · 0 评论 -
HDU - 5113 - Black And White(dfs)
Black And WhiteTime Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 3031 Accepted Submission(s): 831Special JudgeProblem Description原创 2016-09-16 17:03:14 · 359 阅读 · 0 评论 -
LeetCode - 606 - Construct String from Binary Tree
You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be represented by empty parenthesis pair "()". And yo原创 2017-06-18 21:14:51 · 420 阅读 · 0 评论 -
LeetCode - 17 - Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st原创 2017-07-18 18:45:47 · 177 阅读 · 0 评论 -
LeetCode - 139/140 - Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may as原创 2017-08-01 18:32:13 · 213 阅读 · 0 评论 -
LeetCode - 79 - Word Search
Given 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, where "adjacent" cells are those horizontally or vertically原创 2017-08-08 18:20:55 · 191 阅读 · 0 评论 -
LeetCode - 78 - Subsets(求数组全部子集)
Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1],原创 2017-08-08 18:21:18 · 360 阅读 · 0 评论 -
LeetCode - 96/95 - Unique Binary Search Trees
96. Unique Binary Search TreesGiven n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.原创 2017-08-06 22:06:34 · 170 阅读 · 0 评论