Problem
Given a collection of distinct integers, return all possible permutations.
Example:
1 |
|
Given a collection of distinct integers, return all possible permutations.
Example:
1 |
|
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Your goal is to reach the last index in the minimum number of jumps.
Example:
1 |
|
Note:
You can assume that you can always reach the last index.
Given an input string (s
) and a pattern (p
), implement wildcard pattern matching with support for '?'
and '*'
.
1 |
|
The matching should cover the entire input string (not partial).
Note:
s
could be empty and contains only lowercase letters a-z
.p
could be empty and contains only lowercase letters a-z
, and characters like ?
or *
.Example 1:
1 |
|
Example 2:
1 |
|
Example 3:
1 |
|
Example 4:
1 |
|
Example 5:
1 |
|
Given two non-negative integers num1
and num2
represented as strings, return the product of num1
and num2
, also represented as a string.
Example 1:
1 |
|
Example 2:
1 |
|
Note:
The length of both num1
and num2
is < 110.
Both num1
and num2
contain only digits 0-9
.
Both num1
and num2
do not contain any leading zero, except the number 0 itself.
You must not use any built-in BigInteger library or convert the inputs to integer directly.
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image!
Example:
1 |
|
Given an unsorted integer array, find the smallest missing positive integer.
Example 1:
1 |
|
Example 2:
1 |
|
Example 3:
1 |
|
Note:
Your algorithm should run in O(n) time and uses constant extra space.
Given a collection of candidate numbers (candidates
) and a target number (target
), find all unique combinations in candidates
where the candidate numbers sums to target
.
Each number in candidates
may only be used once in the combination.
Note:
All numbers (including target
) will be positive integers.
The solution set must not contain duplicate combinations.
Example 1:
1 |
|
Example 2:
1 |
|
Given a set of candidate numbers (candidates
) (without duplicates) and a target number (target
), find all unique combinations in candidates
where the candidate numbers sums to target
.
The same repeated number may be chosen from candidates
unlimited number of times.
Note:
target
) will be positive integers.Example 1:
1 |
|
Example 2:
1 |
|
The count-and-say sequence is the sequence of integers with the first five terms as following:
1 |
|
1
is read off as "one 1"
or 11
.
11
is read off as "two 1s"
or 21
.
21
is read off as "one 2
, then one 1
” or 1211
.
Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence.
Note: Each term of the sequence of integers will be represented as a string.
Example 1:
1 |
|
1 |
|
Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy all of the following rules:
Each of the digits 1-9
must occur exactly once in each row.
Each of the digits 1-9
must occur exactly once in each column.
Each of the the digits 1-9
must occur exactly once in each of the 9 3x3
sub-boxes of the grid.
Empty cells are indicated by the character '.'
.
A sudoku puzzle…
…and its solution numbers marked in red.
Note:
The given board contain only digits 1-9
and the character '.'
.
You may assume that the given Sudoku puzzle will have a single unique solution.
The given board size is always 9x9
.