File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,393 LeetCode solutions in JavaScript
1
+ # 1,394 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
773
773
958|[ Check Completeness of a Binary Tree] ( ./solutions/0958-check-completeness-of-a-binary-tree.js ) |Medium|
774
774
959|[ Regions Cut By Slashes] ( ./solutions/0959-regions-cut-by-slashes.js ) |Medium|
775
775
960|[ Delete Columns to Make Sorted III] ( ./solutions/0960-delete-columns-to-make-sorted-iii.js ) |Hard|
776
+ 961|[ N-Repeated Element in Size 2N Array] ( ./solutions/0961-n-repeated-element-in-size-2n-array.js ) |Easy|
776
777
962|[ Maximum Width Ramp] ( ./solutions/0962-maximum-width-ramp.js ) |Medium|
777
778
963|[ Minimum Area Rectangle II] ( ./solutions/0963-minimum-area-rectangle-ii.js ) |Medium|
778
779
964|[ Least Operators to Express Number] ( ./solutions/0964-least-operators-to-express-number.js ) |Hard|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 961. N-Repeated Element in Size 2N Array
3
+ * https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
4
+ * Difficulty: Easy
5
+ *
6
+ * You are given an integer array nums with the following properties:
7
+ * - nums.length == 2 * n.
8
+ * - nums contains n + 1 unique elements.
9
+ * - Exactly one element of nums is repeated n times.
10
+ *
11
+ * Return the element that is repeated n times.
12
+ */
13
+
14
+ /**
15
+ * @param {number[] } nums
16
+ * @return {number }
17
+ */
18
+ var repeatedNTimes = function ( nums ) {
19
+ const map = { } ;
20
+ for ( let i = 0 ; i < nums . length ; i ++ ) {
21
+ if ( ! map [ nums [ i ] ] ) map [ nums [ i ] ] = 1 ;
22
+ else return nums [ i ] ;
23
+ }
24
+ } ;
You can’t perform that action at this time.
0 commit comments