随笔分类 -  DFS

摘要:[抄题]: Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string ma 阅读全文
posted @ 2018-05-22 22:02 苗妙苗 阅读(424) 评论(0) 推荐(0)
摘要:[抄题]: 求挖掉一些区域后,能允许出现的最大十字架 In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given list mines which are 0. Wh 阅读全文
posted @ 2018-05-18 09:09 苗妙苗 阅读(180) 评论(0) 推荐(0)
摘要:[抄题]: 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 ch 阅读全文
posted @ 2018-05-14 21:45 苗妙苗 阅读(152) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer t 阅读全文
posted @ 2018-05-13 15:12 苗妙苗 阅读(161) 评论(0) 推荐(0)
摘要:[抄题]: Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where 阅读全文
posted @ 2018-05-06 22:39 苗妙苗 阅读(310) 评论(0) 推荐(0)
摘要:[抄题]: Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. 阅读全文
posted @ 2018-05-06 16:14 苗妙苗 阅读(117) 评论(0) 推荐(0)
摘要:[抄题]: An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate 阅读全文
posted @ 2018-04-29 16:58 苗妙苗 阅读(343) 评论(0) 推荐(0)
摘要:[抄题]: You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates 阅读全文
posted @ 2018-04-24 21:49 苗妙苗 阅读(136) 评论(0) 推荐(0)
摘要:[抄题]: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a lis 阅读全文
posted @ 2018-03-12 10:58 苗妙苗 阅读(422) 评论(0) 推荐(0)
摘要:[抄题]: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tre 阅读全文
posted @ 2018-03-12 09:21 苗妙苗 阅读(179) 评论(0) 推荐(0)
摘要:[抄题]: 求最多的联通的1的数量 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 (horizonta 阅读全文
posted @ 2018-03-11 21:25 苗妙苗 阅读(176) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: [暴力解法]: 时间分析: 空间分析 阅读全文
posted @ 2018-03-11 11:20 苗妙苗 阅读(176) 评论(0) 推荐(0)
摘要:[抄题]: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given 阅读全文
posted @ 2018-03-11 10:52 苗妙苗 阅读(147) 评论(0) 推荐(0)
摘要:[抄题]: 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 阅读全文
posted @ 2018-03-11 09:00 苗妙苗 阅读(141) 评论(0) 推荐(0)