LeetCode 刷题记录: 46. Permutations [Python]

原题

https://leetcode.com/problems/permutations/

Given a collection of distinct integers, return all possible permutations.

思路

Backtrack。当temp长度等于所有数字时,添加进结果。否则遍历数字,每个数字添加进temp中,进行下一次迭代。当temp中存在相同数字时跳过。

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×