/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param str string字符串
* @return string字符串一维数组
*/
function Permutation( str ) {
// write code here
s=str.split('').sort((a,b)=>b-a).join('')//将字符串进行排序
//定义返回数组
const res=[]
//定义dfs
function dfs(curr,store){
//最底部时添加到数组
if(store.length==0){
return res.push(curr)
}
for(let i=0;i<store.length;i++){
//当字符串重复删除
if(i>0 && store[i]===store[i-1]) {
console.log(store[i])
continue
};
//dfs递归
dfs(curr+store[i],store.slice(0,i)+store.slice(i+1))
}
}
//调用执行dfs深度优先遍历
dfs('',s)
//返回结果
return Array.from(new Set(res))
}
module.exports = {
Permutation : Permutation
};