We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 285b307 commit 1568018Copy full SHA for 1568018
00_Arrays/ContainsDuplicate/JS/solution.js
@@ -9,8 +9,8 @@ var containsDuplicateSort = function(nums) {
9
nums.sort((a, b) => a - b)
10
// check if an array elements are equal next to each other
11
// note that the limit is nums.length - 1
12
- for (let i=0; i < nums.length - 1; i++) {
13
- if (nums[i] === nums[i + 1]) return true
+ for (let i=1; i < nums.length - 1; i++) {
+ if (nums[i] === nums[i - 1]) return true
14
}
15
return false
16
};
@@ -25,4 +25,4 @@ var containsDuplicate = function(nums) {
25
set.add(nums[i])
26
27
28
-};
+};
0 commit comments