Skip to main content

Backtracking

This page provides links to solutions that use the backtracking technique.

Overview

Backtracking is a general algorithmic technique used to solve problems by incrementally building candidates.

For example, classic N\text{N} queen problem, for this problem we start by assigning each queen to one of the N\text{N} rows and use backtracking to adjust the placement if the current arrangement does not satisfy the conditions for placing N\text{N} queens on an N×N\text{N} \times \text{N} chessboard.

How to Spot These Problems

You can identify backtracking problems:

  • If the problem requires you to explore all possible outcomes.
  • If the size of the input is very small.

Leetcode Problem Set