8000 Merge pull request #12 from Tahirc1/Tahirc1-update-26 · 96vksinghcort/LeetcodeJs@b1d0308 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1d0308

Browse files
authored
Merge pull request Tahirc1#12 from Tahirc1/Tahirc1-update-26
Update 26. Remove Duplicates from Sorted Array.js
2 parents e33d27b + 919a13d commit b1d0308

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
var removeDuplicates = function(nums) {
2+
// Create a set from nums array
23
let s = new Set(nums)
4+
// convert that set to Array
35
let num = Array.from(s.values())
6+
// replace nums[i] with num[i] we need to update nums
47
for(let i =0; i < num.length ; i++){
58
nums[i] = num[i]
69
}
10+
// return num.length
711
return num.length
8-
};
12+
};

0 commit comments

Comments
 (0)
0