![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
深度优先算法 DFS
我家小狗迷路了
这个作者很懒,什么都没留下…
展开
-
[LeetCode] 690. Employee Importance
Problem :You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id.For example, employee 1 is the原创 2017-10-07 11:19:44 · 195 阅读 · 0 评论 -
[LeetCode] 747. Min Cost Climbing Stairs
Problem:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to原创 2018-01-03 21:03:40 · 184 阅读 · 0 评论 -
[LeetCode] 394. Decode String
Problem:Given 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.原创 2018-01-02 12:31:57 · 181 阅读 · 0 评论 -
[LeetCode] 337. House Robber III
Problem:The 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原创 2017-12-17 21:55:41 · 155 阅读 · 0 评论 -
[LeetCode] Convert Sorted Array to Binary Search Tree
Problem:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which原创 2017-12-16 13:13:54 · 148 阅读 · 0 评论 -
[LeetCode] 100. Same Tree
Problem:Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same原创 2017-12-16 11:45:29 · 144 阅读 · 0 评论 -
[LeetCode] 515. Find Largest Value in Each Tree Row
Problem:You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]解法原创 2017-11-18 14:32:33 · 173 阅读 · 0 评论 -
[LeetCode] 547. Friend Circles
Problem:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct frie原创 2017-12-15 23:38:47 · 195 阅读 · 0 评论 -
[LeetCode] 416. Partition Equal Subset Sum
Problem:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Eac原创 2017-12-21 19:28:48 · 145 阅读 · 0 评论 -
[LeetCode] 199. Binary Tree Right Side View
Problem:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary原创 2017-12-23 13:40:19 · 139 阅读 · 0 评论 -
[LeetCode] 494. Target Sum
Problem:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbo原创 2017-12-21 20:36:16 · 143 阅读 · 0 评论 -
[LeetCode] 695. Max Area of Island
Problem:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of t原创 2017-11-28 19:19:11 · 246 阅读 · 0 评论 -
[LeetCode] 513. Find Bottom Left Tree Value
Problem:Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \原创 2017-10-15 23:58:21 · 154 阅读 · 0 评论 -
[剑指offer] 重建二叉树
Description:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。Solution:/** * Definition for binary tree * public class TreeNode {...原创 2018-03-31 16:53:11 · 125 阅读 · 0 评论