1. 首页
  2. 数据库
  3. 其它
  4. leetcode 46. Permutations 迭代+递归 python3

leetcode 46. Permutations 迭代+递归 python3

上传者: 2020-12-31 09:03:08上传 PDF文件 43.68KB 热度 10次
一.问题描述 Given a collection of distinct integers, return all possible permutations. Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 二.解题思路 主要是有两种思路: 1,数组长度为n,后面i~n的子数组已完成全排列,我们慢慢向前推进,接下来把nums[i-1]加进去,来完成新子数组的全排列,方法就是把nums[i-1]插入i~n子数组所有全排列的结果中的每个可能
下载地址
用户评论