
Depth First Search
Arcome
这个作者很懒,什么都没留下…
展开
-
LeetCode #110 - Balanced Binary Tree - Easy
ProblemGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never dif原创 2016-11-12 22:04:34 · 463 阅读 · 0 评论 -
LeetCode #104 - Maximum Depth of Binary Tree - Easy
ProblemGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Subscribe to see which companies ask原创 2016-11-07 21:40:31 · 784 阅读 · 0 评论 -
LeetCode #100 - Same Tree - Easy
ProblemGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. ExampleDete原创 2016-11-09 18:36:25 · 449 阅读 · 0 评论 -
LeetCode #337 - House Robber III - Medium
ProblemThe thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After原创 2016-11-09 18:54:04 · 420 阅读 · 0 评论 -
LeetCode #108 - Convert Sorted Array to Binary Search Tree -Medium
ProblemGiven an array where elements are sorted in ascending order, convert it to a height balanced BST. ExampleInput:[1,2,3] Output: 1 /\ 2 3 Algorithm整理一下题意:给定一个升序数组,要求将其转化为一课平衡二叉树经典的树类型题目。采原创 2016-11-12 00:16:00 · 353 阅读 · 0 评论 -
LeetCode #394 - Decode String -Medium
ProblemGiven an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is原创 2016-11-12 10:21:42 · 402 阅读 · 0 评论 -
LeetCode #101 - Symmetric Tree - Easy
ProblemGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). Example this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3But t原创 2016-11-12 22:02:54 · 404 阅读 · 0 评论 -
2017.1.10 算法测试题集 - 1003 - 1的块数
Problem给定一个0-1矩阵matrix,相邻的1视为“同一块”,问矩阵matrix有多少块1? Example[1, 0, 0] [0, 1, 0] [0, 0, 1] Return 3[1, 0, 0, 1] [0, 1, 1, 0] [0, 0, 0, 1] Return 4; Algorithm通过深度优先搜索来解决。遍历矩阵,若访问到1,则将这个1以及与它相连的所有1都置为0,同时块数原创 2017-01-13 17:06:10 · 590 阅读 · 0 评论