leetcode-dfs
proudmore
这个作者很懒,什么都没留下…
展开
-
Leetcode N-Queens I, II
N-Queens IThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puz原创 2015-03-19 07:22:02 · 153 阅读 · 0 评论 -
Leetcode Generate parentheses
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: “((()))”, “(()())”, “(())()”, “()(())”, “()()()”[c原创 2015-03-20 13:38:05 · 193 阅读 · 0 评论 -
Leetcode Restore ip addresses
public class Solution { public List<String> restoreIpAddresses(String s) { List<String> list=new List<String>(); if(s==null || s.length==null)return list; String[] path=new原创 2015-03-19 08:13:56 · 175 阅读 · 0 评论 -
Leetcode Combination sum I, II
Combination sum IGiven 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 repeated number may be chosen from C un原创 2015-03-20 13:28:59 · 136 阅读 · 0 评论 -
Leetcode Word search
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 “adjacent” cells are those horizontally or vertically neig原创 2015-03-21 00:59:09 · 140 阅读 · 0 评论 -
Leetcode Number of islands
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 adjacent lands horizontally or vertically. You may assume原创 2015-05-08 02:55:23 · 158 阅读 · 0 评论 -
Leetcode Word Search II
Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizont原创 2015-05-20 07:53:27 · 158 阅读 · 0 评论 -
Leetcode Course Schedule I, II
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:原创 2015-05-08 07:27:04 · 254 阅读 · 0 评论 -
Leetcode letter combination of a phone number
public class Solution { public List<String> letterCombinations(String digits) { list=new ArrayList<String>(); if(digits.length()==0)return list; StringBuffer path=new String原创 2015-06-09 08:38:10 · 181 阅读 · 0 评论