随笔分类 - 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: [
阅读全文
摘要:Write a function to generate the generalized abbreviations of a word. Note: The order of the output does not matter. Example: Input: "word" Output: ["
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. A valid IP address consists of exactly four
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. 'M' represents an unreveal
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文

浙公网安备 33010602011771号