![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DFS
文章平均质量分 74
伊萨卡钢琴家
这个作者很懒,什么都没留下…
展开
-
Leetcode@word search
For this problem, it is a common depth first search problem, and use the visited boolean array to judge if the char element has been visited before. one problem I meet if that start means the number原创 2016-01-20 06:42:53 · 243 阅读 · 0 评论 -
Leetcode 124. Binary Tree Maximum Path Sum
Given a binary 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 connections. The原创 2016-01-27 01:36:15 · 273 阅读 · 0 评论 -
114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:analysis原创 2016-01-27 01:28:23 · 269 阅读 · 0 评论 -
Leetcode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric:Analysis: 判断左右的节点是否对称/** * Definition for a binary原创 2016-01-27 01:05:14 · 260 阅读 · 0 评论 -
Leetcode 326. Power of Three
Given an integer, write a function to determine if it is a power of three.这个是Power of two 的兄弟题,他的兄弟可以用Bit Manipulation做,但是它不可以这里用了DFS搜索做public class Solution { public boolean isPowerOfThree(原创 2016-01-25 13:01:43 · 292 阅读 · 0 评论 -
Leetcode 37. Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku原创 2016-01-25 06:05:12 · 241 阅读 · 0 评论 -
Leetcode 301. Remove Invalid Parentheses
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( and ).原创 2016-01-21 13:42:31 · 469 阅读 · 0 评论 -
Leetcode 130. Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.Analysis: This question i转载 2016-01-21 05:04:35 · 342 阅读 · 0 评论 -
Subsets II @Leetcode
Subsets II //Given a collection of integers that might contain duplicates, nums, return all possible subsets.//For example, If nums = [1,2,2], a solution is: [/** [2], [1], [1,2,2],原创 2016-01-20 13:59:18 · 378 阅读 · 0 评论 -
Depth-first-search的总结
几个技巧,在树中的先序遍历就是对应的Depth-first-search.100. Same Tree https://leetcode.com/problems/same-tree/遍历树的节点,判断树节点的node的val是否一致,并且递归判断左右孩子301. Remove Invalid Parentheses https://leetcode.com/p原创 2016-01-27 01:38:56 · 541 阅读 · 0 评论