Depth-firstSearch
weixin_39145266
这个作者很懒,什么都没留下…
展开
-
1102 Path With Maximum Minimum Value
1 题目Given amatrix of integersAwithRrows andCcolumns, findthemaximumscoreof a path starting at[0,0]and ending at[R-1,C-1].Thescoreof a path is theminimumvalue in that path. For e...原创 2019-12-20 14:06:51 · 169 阅读 · 0 评论 -
124 Binary Tree Maximum Path Sum
1 题目Given anon-emptybinary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child con...原创 2019-12-20 08:02:53 · 70 阅读 · 0 评论 -
472 Concatenated Words
1 题目Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.A concatenated word is defined as a string that is comprised e...原创 2019-12-01 13:00:20 · 76 阅读 · 0 评论 -
980 Unique Paths III
1 题目On a 2-dimensionalgrid, there are 4 types of squares:1represents the starting square. There is exactly one starting square. 2represents the ending square. There is exactly one ending squ...原创 2019-11-24 14:54:06 · 67 阅读 · 0 评论 -
207 Course Schedule
1 题目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...原创 2019-04-23 10:19:55 · 58 阅读 · 0 评论 -
207 Course Schedule
1 题目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...原创 2019-04-23 10:39:38 · 73 阅读 · 0 评论 -
108 Convert Sorted Array to Binary Search Tree
1 题目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 the depth ...原创 2019-05-06 16:26:02 · 51 阅读 · 0 评论 -
110 Balanced Binary Tree
1 题目Given 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 ofeverynode never...原创 2019-05-06 17:02:07 · 50 阅读 · 0 评论 -
417 Pacific Atlantic Water Flow
1 题目Given anm x nmatrix 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"...原创 2019-07-12 22:05:50 · 151 阅读 · 0 评论 -
394 Decode String
1 题目Given an encoded string, return its decoded string.The encoding rule is:k[encoded_string], where theencoded_stringinside the square brackets is being repeated exactlyktimes. Note thatki...原创 2019-07-09 22:25:38 · 57 阅读 · 0 评论 -
337 House Robber III
1 题目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. After ...原创 2019-07-04 22:52:16 · 90 阅读 · 0 评论 -
332 Reconstruct Itinerary
1 题目Given a list of airline tickets represented by pairs of departure and arrival airports[from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs fromJFK. Th...原创 2019-07-06 22:00:19 · 101 阅读 · 0 评论 -
116 Populating Next Right Pointers in Each Node
1 题目You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *le...原创 2019-04-15 15:42:09 · 74 阅读 · 0 评论 -
133 Clone Graph
Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors.Example:...原创 2019-04-17 14:22:44 · 86 阅读 · 0 评论 -
98 Validate Binary Search Tree
1 题目Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key....原创 2019-04-01 17:49:11 · 56 阅读 · 0 评论 -
105 Construct Binary Tree from Preorder and Inorder Traversal
1 题目Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder =[3,9,20,15,7]inorder ...原创 2019-04-01 21:35:46 · 53 阅读 · 0 评论 -
106 Construct Binary Tree from Inorder and Postorder Traversal
1 题目Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder =[9,3,15,20,7]postorde...原创 2019-04-01 21:37:45 · 47 阅读 · 0 评论 -
113 Path Sum II
1 题目Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note:A leaf is a node with no children.Example:Given the below binary tree andsum = ...原创 2019-04-02 11:32:37 · 55 阅读 · 0 评论 -
117 Populating Next Right Pointers in Each Node II
1 题目Given a binary treestruct Node { int val; Node *left; Node *right; Node *next;}Populate each next pointer to point to its next right node. If there is no next right node, the next p...原创 2019-04-15 16:18:56 · 72 阅读 · 0 评论 -
129 Sum Root to Leaf Numbers
1 题目Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find t...原创 2019-04-15 16:28:06 · 71 阅读 · 0 评论 -
200 Number of Islands
1 题目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...原创 2019-04-12 15:37:25 · 66 阅读 · 0 评论 -
199 Binary Tree Right Side View
1 题目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.Example:Input: [1,2,3,null,5,null,4]Output: [1...原创 2019-04-12 16:04:51 · 70 阅读 · 0 评论 -
130 Surrounded Regions
1 题目Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.Example:X X X X...原创 2019-04-12 16:47:17 · 118 阅读 · 0 评论 -
109 Convert Sorted List to Binary Search Tree
1 题目convert it to a height balanced BST.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 differ by more than ...原创 2019-04-17 11:26:42 · 70 阅读 · 0 评论 -
257 Binary Tree Paths
1 题目Given a binary tree, return all root-to-leaf paths.Note:A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Explanation: A...原创 2019-04-26 10:10:32 · 58 阅读 · 0 评论 -
114 Flatten Binary Tree to Linked List
1 题目Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 ...原创 2019-04-05 15:42:01 · 74 阅读 · 0 评论