← Backtracking

Pattern Recognition Drill

#77 — Permutations

Medium Backtracking

The Problem

Return all permutations of a list of distinct integers.

What approach would you use?

Think about it before scrolling down.

Key Signals

Backtracking

At each position, choose from unused elements. Track used set. Collect when path length = n. O(n! * n).

Common Trap

Don't confuse with combinations. Permutations care about order: [1,2] ≠ [2,1].

← #76 #78 →