mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
纠正 0047.全排列II JS、TS 版本代码
JS 和 TS 里面 数组深拷贝一般采用 ES6 扩展运算符 ... ,或者 Array.from() 方法,而不会采用实例方法 slice. slice方法用于数组分割等操作,请注意代码书写规范!
This commit is contained in:
@ -268,7 +268,7 @@ var permuteUnique = function (nums) {
|
|||||||
|
|
||||||
function backtracing( used) {
|
function backtracing( used) {
|
||||||
if (path.length === nums.length) {
|
if (path.length === nums.length) {
|
||||||
result.push(path.slice())
|
result.push([...path])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (let i = 0; i < nums.length; i++) {
|
for (let i = 0; i < nums.length; i++) {
|
||||||
@ -303,7 +303,7 @@ function permuteUnique(nums: number[]): number[][] {
|
|||||||
return resArr;
|
return resArr;
|
||||||
function backTracking(nums: number[], route: number[]): void {
|
function backTracking(nums: number[], route: number[]): void {
|
||||||
if (route.length === nums.length) {
|
if (route.length === nums.length) {
|
||||||
resArr.push(route.slice());
|
resArr.push([...route]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = 0, length = nums.length; i < length; i++) {
|
for (let i = 0, length = nums.length; i < length; i++) {
|
||||||
|
Reference in New Issue
Block a user