core practice · coding problem

Permutations

LeetCode #46 — Permutations. Solve on LeetCode, then implement here if you want it in your drill queue. https://leetcode.com/problems/permutations/

The mechanism

Backtracking is "try a choice, recurse, undo if it does not work, try the next one." It explores all possibilities, but you cut whole branches by stopping early when you can prove they will never reach a valid answer.

Study Backtracking

Expected evidence

Pass all LeetCode test cases for this problem.

Try this drill in the practice workspace →

Hints when you need them
  • Pattern hint: backtracking.
  • Start with brute force, then optimize time/space.
  • Write down invariants before coding.

Check the sources

Practice the same mechanism

Browse all practice briefs