/**
*
* @param num int整型一维数组
* @return int整型二维数组
*/
function permuteUnique( num ) {
// write code here
let res = [];
let len = num.length;
num.sort((a,b)=>{return(a-b)})
const dfs=(temp,index,now)=>{
if(temp.length==len){
res.push([...temp]);
};
for(let i = 0;i<index.length;i++){
if(index[i] == index[i-1]){
continue
}
dfs([...temp,index[i]],index.slice(0,i).concat(index.slice(i+1)));
}
}
dfs([],num);
res.sort();
console.log(Array.from(new Set(res)))
return res;
}
module.exports = {
pejavascript:void(0);rmuteUnique : permuteUnique
};
*
* @param num int整型一维数组
* @return int整型二维数组
*/
function permuteUnique( num ) {
// write code here
let res = [];
let len = num.length;
num.sort((a,b)=>{return(a-b)})
const dfs=(temp,index,now)=>{
if(temp.length==len){
res.push([...temp]);
};
for(let i = 0;i<index.length;i++){
if(index[i] == index[i-1]){
continue
}
dfs([...temp,index[i]],index.slice(0,i).concat(index.slice(i+1)));
}
}
dfs([],num);
res.sort();
console.log(Array.from(new Set(res)))
return res;
}
module.exports = {
pejavascript:void(0);rmuteUnique : permuteUnique
};