随笔分类 -  dfs&bfs

摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["2 阅读全文
posted @ 2016-12-03 06:02 微微程序媛 阅读(166) 评论(0) 推荐(0)
摘要:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be 阅读全文
posted @ 2016-12-02 02:26 微微程序媛 阅读(202) 评论(0) 推荐(0)
摘要:Given an 2D board, count how many different battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. Y 阅读全文
posted @ 2016-11-28 06:19 微微程序媛 阅读(220) 评论(0) 推荐(0)
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: 阅读全文
posted @ 2016-11-28 00:38 微微程序媛 阅读(167) 评论(0) 推荐(0)
摘要:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeat 阅读全文
posted @ 2016-11-17 01:40 微微程序媛 阅读(120) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-10-11 08:44 微微程序媛 阅读(134) 评论(0) 推荐(0)
摘要:You are given a m x n 2D grid initialized with these three possible values. Fill each empty room with the distance to its nearest gate. If it is impos 阅读全文
posted @ 2016-10-11 08:43 微微程序媛 阅读(157) 评论(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 @ 2016-10-11 08:39 微微程序媛 阅读(115) 评论(0) 推荐(0)