Skip to main content
332, Reconstruct Itinerary

I Problem

You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.

All of the tickets belong to a man who departs from "JFK", thus, the itinerary must begin with "JFK". If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string.


MikeAbout 2 minbacktrackingmediumdepth first searchgraphbacktracking
491, Non-decreasing Subsequences

I Problem

Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may return the answer in any order.

Example 1
Input: nums = [4, 6, 7, 7]
Output: [[4, 6], [4, 6, 7], [4, 6, 7, 7], [4, 7], [4, 7, 7], [6, 7], [6, 7, 7], [7, 7]]


MikeAbout 1 minbacktrackingmediumarrayhash tablebit manipulationbacktracking
37, Sudoku Solver

I Problem

Write a program to solve a Sudoku puzzle by filling the empty cells.

A sudoku solution must satisfy all of the following rules:

  1. Each of the digits 1-9 must occur exactly once in each row.
  2. Each of the digits 1-9 must occur exactly once in each column.
  3. Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.

MikeAbout 4 minbacktrackinghardarrayhash tablematrixbacktracking
52, N-Queens II

I Problem

The n-queens puzzle is the problem of placing nqueens on an n x n chessboard such that no two queens attack each other.

Given an integer n, return the number of distinct solutions to the n-queens puzzle.


MikeAbout 1 minbacktrackinghardbacktracking
51, N-Queens

I Problem

The n-queens puzzle is the problem of placing nqueens on an n x n chessboard such that no two queens attack each other.

Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.


MikeAbout 1 minbacktrackinghardarraybacktracking
47, Permutations II

I Problem

Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

Example 1
Input: nums = [1, 1, 2]
Output: [[1, 1, 2], [1, 2, 1], [2, 1, 1]]

Example 2
Input: nums = [1, 2, 3]
Output: [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]


MikeAbout 2 minbacktrackingmediumarraybacktracking
46, Permutations

I Problem

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Example 1
Input: nums = [1, 2, 3]
Output: [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]


MikeAbout 1 minbacktrackingmediumarraybacktracking
90, Subsets II

I Problem

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

The solution set must not contain duplicate subsets. Return the solution in any order.

Example 1
Input: nums = [1, 2, 2]
Output: [[], [1], [1, 2], [1, 2, 2], [2], [2, 2]]


MikeAbout 1 minbacktrackingmediumarraybacktrackingbit manipulation
78, Subsets

I Problem

Given an integer array nums of unique elements, return all possible subsets (the power set).

The solution set must not contain duplicate subsets. Return the solution in any order.

Example 1
Input: nums = [1, 2, 3]
Output: [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]


MikeAbout 1 minbacktrackingmediumarraybacktrackingbit manipulation
93, Restore IP Addresses

I Problem

A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros.

  • For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses, but "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses.

MikeAbout 1 minbacktrackingmediumstringbacktracking
2