1、全排列
    https://leetcode-cn.com/problems/permutations/

    1. var permute = function(nums) {
    2. const res = []
    3. var perm = function (nums, start, end) {
    4. if (start == end) {
    5. //拷贝数组
    6. //重要
    7. res.push(nums.concat())
    8. } else {
    9. for (let i = start; i <= end; i++) {
    10. swap(nums, start, i)
    11. perm(nums, start+1, end)
    12. swap(nums, start, i)
    13. }
    14. }
    15. }
    16. perm(nums, 0 ,nums.length - 1)
    17. return res
    18. };
    19. var swap = function (nums, a, b) {
    20. let c = nums[b]
    21. nums[b] = nums[a]
    22. nums[a] = c
    23. }

    2、数组的子集
    https://www.cnblogs.com/linx/p/7568375.html