Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd706ef

Browse files
committed
Time: 9 ms (78.22%), Space: 39.2 MB (49.34%) - LeetHub
1 parent 0c02c76 commit dd706ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

0046-permutations/0046-permutations.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Solution {
66
current: MutableList<Int>,
77
) {
88
if (current.size == nums.size) {
9-
result += current
9+
result += current.toMutableList()
1010
return
1111
}
1212
for (i in nums.indices) {
@@ -15,9 +15,9 @@ class Solution {
1515
}
1616

1717
used[i] = true
18-
val next = current.toMutableList()
19-
next += nums[i]
20-
backtrack(nums, result, used, next)
18+
current += nums[i]
19+
backtrack(nums, result, used, current)
20+
current.removeLast()
2121
used[i] = false
2222
}
2323
}

0 commit comments

Comments
 (0)