描述
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
分析跟上一题其实完全一样,不用维护路径,只
...
描述
Given an integer n, return all distinct solutions to the n-queens puzzle.
Each solution contains a distinct board configuration of the n-queens’ p
...
描述
Follow up for “Unique Paths”:
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty sp
...
描述
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).
The robot can only move either down or right at an
...
描述
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partition
...
描述
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For exa
...
描述
Given a 2D board containing ‘X’ and ‘O’, capture all regions surrounded by ‘X’.
A region is captured by flipping all ‘O’s into ‘X’s in that surroun
...
描述
Given two words (start and end), and a dictionary’s word list, find all shortest transformation sequence(s) from start to end, such that:
Only one
...
描述
Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that
...
描述
Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the tele
...
描述
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:
[ [2,4], [
...
描述
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,[1,1,2] have the following unique
...
描述
Given a collection of numbers, return all possible permutations.
For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,
...
描述
Given a collection of integers that might contain duplicates, nums, return all possible subsets.
Note:Elements in a subset must be in non-descendin
...
描述
Given a set of distinct integers, nums, return all possible subsets.
Note:Elements in a subset must be in non-descending order.The solution set mus
...