全排列

LeetCode Hot 100 回溯
难度: 中等

题目描述

给定一个不含重复数字的数组,返回其所有可能的排列。

解题思路

使用回溯法,递归地交换每个位置的元素并生成排列。时间复杂度为 O(n!)。