随笔分类 -  DFS

摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ 阅读全文
posted @ 2020-07-27 23:16 苗妙苗 阅读(106) 评论(0) 推荐(0)
摘要:Write a function to generate the generalized abbreviations of a word. Note: The order of the output does not matter. Example: Input: "word" Output: [" 阅读全文
posted @ 2020-07-27 11:17 苗妙苗 阅读(98) 评论(0) 推荐(0)
摘要:Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the d 阅读全文
posted @ 2020-07-27 01:44 苗妙苗 阅读(163) 评论(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 choose o 阅读全文
posted @ 2020-07-25 11:16 苗妙苗 阅读(100) 评论(0) 推荐(0)
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. A valid IP address consists of exactly four 阅读全文
posted @ 2020-07-23 20:38 苗妙苗 阅读(172) 评论(0) 推荐(0)
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le 阅读全文
posted @ 2020-07-18 08:18 苗妙苗 阅读(141) 评论(0) 推荐(0)
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le 阅读全文
posted @ 2020-07-10 09:34 苗妙苗 阅读(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 "adjac 阅读全文
posted @ 2020-07-07 23:01 苗妙苗 阅读(207) 评论(0) 推荐(0)
摘要: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 adjacen 阅读全文
posted @ 2020-07-06 22:13 苗妙苗 阅读(161) 评论(0) 推荐(0)
摘要: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.) Yo 阅读全文
posted @ 2020-07-06 11:01 苗妙苗 阅读(108) 评论(0) 推荐(0)
摘要: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.) Yo 阅读全文
posted @ 2020-07-04 22:39 苗妙苗 阅读(129) 评论(0) 推荐(0)
摘要:[抄题]: Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like 阅读全文
posted @ 2018-08-28 20:46 苗妙苗 阅读(401) 评论(0) 推荐(0)
摘要:[抄题]: Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时 阅读全文
posted @ 2018-08-08 17:19 苗妙苗 阅读(318) 评论(0) 推荐(0)
摘要:[抄题]: 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 vertica 阅读全文
posted @ 2018-08-08 10:55 苗妙苗 阅读(323) 评论(0) 推荐(0)
摘要:[抄题]: Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. 'M' represents an unreveal 阅读全文
posted @ 2018-08-04 10:29 苗妙苗 阅读(381) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. Please optimize your 阅读全文
posted @ 2018-08-01 22:32 苗妙苗 阅读(191) 评论(0) 推荐(0)
摘要:[抄题]: Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You m 阅读全文
posted @ 2018-07-31 16:38 苗妙苗 阅读(132) 评论(0) 推荐(0)
摘要:[抄题]: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set 阅读全文
posted @ 2018-07-28 20:56 苗妙苗 阅读(244) 评论(0) 推荐(0)
摘要:[抄题]: Numbers can be regarded as product of its factors. For example, Write a function that takes an integer n and return all possible combinations of 阅读全文
posted @ 2018-07-28 15:37 苗妙苗 阅读(149) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into knon-empty subsets whose sums are 阅读全文
posted @ 2018-07-27 10:11 苗妙苗 阅读(256) 评论(0) 推荐(0)