Skip to content

Commit f6b001d

Browse files
committed
Runtime: 122 ms (Top 61.38%) | Memory: 44.5 MB (Top 89.57%)
1 parent d4e7d91 commit f6b001d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 122 ms (Top 61.38%) | Memory: 44.5 MB (Top 89.57%)
12
var permuteUnique = function(nums) {
23
const answer = []
34

@@ -6,7 +7,7 @@ var permuteUnique = function(nums) {
67
if (pos >= array.length) {
78
answer.push(array)
89
}
9-
10+
1011
const setObject = new Set()
1112

1213
for (let index=pos; index<array.length; index++) {
@@ -15,15 +16,15 @@ var permuteUnique = function(nums) {
1516
}
1617
setObject.add(array[index])
1718

18-
// swap numbers
19+
// swap numbers
1920
let temp = array[pos]
2021
array[pos] = array[index]
2122
array[index] = temp
22-
23+
2324
perm(pos + 1, [...array])
24-
25+
2526
// undo swapping for next iteration
26-
temp = array[index]
27+
temp = array[index]
2728
array[index] = array[pos]
2829
array[pos] = temp
2930
}
@@ -32,4 +33,4 @@ var permuteUnique = function(nums) {
3233
perm(0, nums)
3334

3435
return answer
35-
};
36+
};

0 commit comments

Comments
 (0)