美文网首页
46. Permutations

46. Permutations

作者: 我是你的果果呀 | 来源:发表于2016-12-16 08:11 被阅读0次

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

For example,
[1,2,3]have the following permutations:
[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ]

backtracking  子串长度够了就加到返回list 里, 始终从0开始扫描, 如果子串里含有当前数字, 则继续,不递归, 否则将当前值加入到子串中,递归,回溯。

相关文章

网友评论

      本文标题:46. Permutations

      本文链接:https://www.haomeiwen.com/subject/miqnmttx.html