全排列
Permutations
题目详情
问题:全排列
考察:数组、回溯
来源:DSA Prep / Citadel
链接:https://leetcode.com/problems/permutations
Problem: Permutations
Patterns: Array, Backtracking
Recency: 2yr
Link: https://leetcode.com/problems/permutations
Source: https://www.dsaprep.dev/blog/citadel-coding-interview-questions/
解析
思路:回溯构造排列,用 used 数组标记哪些数字已被选择。路径长度达到 n 时记录一个排列。
复杂度:时间 O(n! * n),空间 O(n) 不计输出。