已解决
46.全排列-py
来自网友在路上 187887提问 提问时间:2023-11-20 04:11:54阅读次数: 87
最佳答案 问答题库878位专家为你答疑解惑
46.全排列
class Solution(object):def permute(self, nums):""":type nums: List[int]:rtype: List[List[int]]"""# 结果数组0ans=[]n=len(nums)# 判断是否使用state_=[False]*n# 临时状态数组dp_=[]def dfs (index):# 终止条件if index==n:ans.append(dp_[:])return for i in range (n):if not state_[i]:state_[i]=Truedp_.append(nums[i])dfs(index+1)dp_.pop()state_[i]=Falsedfs(0)return ans
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"46.全排列-py":http://eshow365.cn/6-39974-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: 常见面试题-MySQL软删除以及索引结构
- 下一篇: 『 MySQL数据库 』数据库之表的约束