给定一个 没有重复 数字的序列,返回其所有可能的全排列。
/*** 回溯 + 剪枝* 时间复杂度:O(n×n!)* 空间复杂度:O(n)*/var permute = function (nums) {const res = []function dps(temp) {if (temp.length === nums.length) {res.push([...temp])return}for (let i = 0; i < nums.length; i++) {if (temp.includes(nums[i])) continuetemp.push(nums[i])dps(temp)temp.pop()}}dps([])return res}
