S**Y 发帖数: 136 | 1 有重复元素的排列,递归算法应该怎么做呢?
比如( 1 2 3 3)
则输出: 1233 1323 1332 2133 2313 2331 ,etc. |
z***e 发帖数: 5393 | 2 permutation is based on index, not the value itself.
【在 S**Y 的大作中提到】 : 有重复元素的排列,递归算法应该怎么做呢? : 比如( 1 2 3 3) : 则输出: 1233 1323 1332 2133 2313 2331 ,etc.
|
g*******y 发帖数: 1930 | 3 three ways:
1. implement and call next_permutation();
2. modify the original permutation algorithm by using strchr(), for details search bullmj's post before.
3. recursion + list (linked list); maintain the list that you operate on is always sorted (faster than array because you can do O(1) insert/delete)
【在 S**Y 的大作中提到】 : 有重复元素的排列,递归算法应该怎么做呢? : 比如( 1 2 3 3) : 则输出: 1233 1323 1332 2133 2313 2331 ,etc.
|
n*******s 发帖数: 482 | 4 2. recursion + list (linked list);
是说 按正常permutation生成,存储结果,检测重复项么? |
s*****r 发帖数: 773 | 5 你没理解题目
【在 z***e 的大作中提到】 : permutation is based on index, not the value itself.
|
s*****d 发帖数: 43 | 6 小羊,
可否给个LINK?找不到bullmj的post.谢过先。
details search bullmj's post before.
is always sorted (faster than array because you can do O(1) insert/delete)
【在 g*******y 的大作中提到】 : three ways: : 1. implement and call next_permutation(); : 2. modify the original permutation algorithm by using strchr(), for details search bullmj's post before. : 3. recursion + list (linked list); maintain the list that you operate on is always sorted (faster than array because you can do O(1) insert/delete)
|