输入: [1,2,3]
输出:
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]
const permute=(arr)=>{const len=arr.length;const result;const backstrak=(currentIndex)=>{if(currentIndex===len){result.push(arr);return;}for(let i=0;i<len;i++){[arr[i],arr[currentIndex]]=[arr[currentIndex],arr[i]];backstrak(currentIndex+1);[arr[i],arr[currentIndex]]=[arr[currentIndex],arr[i]];}}return result;}
