90. Subsets II

Problem description:

Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).

Note: The solution set must not contain duplicate subsets.

1
2
3
4
5
6
7
8
9
10
11
12
Example:

Input: [1,2,2]
Output:
[
[2],
[1],
[1,2,2],
[2,2],
[1,2],
[]
]

Readmore

78. Subsets

Problem description:

Given a set of distinct integers, nums, return all possible subsets (the power set).

Readmore

105. Construct Binary Tree from Preorder and Inorder Traversal

Problem description:

Given preorder and inorder traversal of a tree, construct the binary tree.

Readmore

Tree traversal

example:

DFS:
Inorder: (Left, Root, Right), 4 2 5 1 3
Preorder: (Root, Left, Right), 1 2 4 5 3
Postorder:(Left, Right, Root), 4 5 2 3 1

Readmore

442. Find All Duplicates in an Array

Problem description:

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

Find all the elements that appear twice in this array.

Readmore

64. Minimum Path Sum

Problem description:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

Readmore

377. Combination Sum IV

Problem description:

Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Example:

nums = [1, 2, 3]
target = 4

The possible combination ways are:
(1, 1, 1, 1)
(1, 1, 2)
(1, 2, 1)
(1, 3)
(2, 1, 1)
(2, 2)
(3, 1)

Note that different sequences are counted as different combinations.

Therefore the output is 7.

Readmore

216. Combination Sum III

Problem description:

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 a unique set of numbers.

Readmore

40. Combination Sum II

Problem description:

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.

Readmore

39. Combination Sum

Problem description:

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.

Readmore