
Depth-first-search
文章平均质量分 81
Yingying_code
这个作者很懒,什么都没留下…
展开
-
106. Construct Binary Tree from Inorder and Postorder Traversal**
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Recursive:public class Solution { public TreeNod原创 2017-01-25 23:06:53 · 276 阅读 · 0 评论 -
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-01-30 17:10:30 · 232 阅读 · 0 评论 -
394. Decode String**
Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_stringinside the square brackets is being repeated exactly k times. Note thatk is g原创 2017-01-30 16:54:41 · 258 阅读 · 0 评论 -
133. Clone Graph**
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each原创 2017-01-29 23:27:59 · 270 阅读 · 0 评论 -
98. Validate Binary Search Tree**
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 keys less than the node's key.Th原创 2017-01-29 22:50:58 · 270 阅读 · 0 评论 -
210. Course Schedule II**
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-01-29 16:16:51 · 254 阅读 · 0 评论 -
207. 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-01-29 15:27:02 · 305 阅读 · 0 评论 -
473. Matchsticks to Square**
Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You shoul原创 2017-01-27 19:57:12 · 243 阅读 · 0 评论 -
332. Reconstruct Itinerary**
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 from JFK. Thus,原创 2017-01-25 23:36:43 · 399 阅读 · 0 评论 -
130. Surrounded Regions**
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.For example,原创 2017-01-30 17:51:27 · 286 阅读 · 0 评论