Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

nums =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Build permutations by choosing an unused element at each position.

Approach

Backtrack with a used[] array. When path length equals n, record it.

Why it works

Each recursion level selects one distinct element for the next position, generating all n! orderings.

Code
Loading...
Complexity
Time: O(n*n!)
Space: O(n)
Solution
Updated: 2026-02-23

Idea

Build permutations by choosing an unused element at each position.

Approach

Backtrack with a used[] array. When path length equals n, record it.

Why it works

Each recursion level selects one distinct element for the next position, generating all n! orderings.

Code
Loading...
Complexity
Time: O(n*n!)
Space: O(n)