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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy