File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 269526953272|[ Find the Count of Good Integers] ( ./solutions/3272-find-the-count-of-good-integers.js ) |Hard|
269626963279|[ Maximum Total Area Occupied by Pistons] ( ./solutions/3279-maximum-total-area-occupied-by-pistons.js ) |Hard|
269726973284|[ Sum of Consecutive Subarrays] ( ./solutions/3284-sum-of-consecutive-subarrays.js ) |Medium|
2698+ 3289|[ The Two Sneaky Numbers of Digitville] ( ./solutions/3289-the-two-sneaky-numbers-of-digitville.js ) |Easy|
269826993294|[ Convert Doubly Linked List to Array II] ( ./solutions/3294-convert-doubly-linked-list-to-array-ii.js ) |Medium|
269927003299|[ Sum of Consecutive Subsequences] ( ./solutions/3299-sum-of-consecutive-subsequences.js ) |Hard|
270027013304|[ Find the K-th Character in String Game I] ( ./solutions/3304-find-the-k-th-character-in-string-game-i.js ) |Easy|
Original file line number Diff line number Diff line change 1+ /**
2+ * 3289. The Two Sneaky Numbers of Digitville
3+ * https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/
4+ * Difficulty: Easy
5+ *
6+ * In the town of Digitville, there was a list of numbers called nums containing integers
7+ * from 0 to n - 1. Each number was supposed to appear exactly once in the list, however,
8+ * two mischievous numbers sneaked in an additional time, making the list longer than usual.
9+ *
10+ * As the town detective, your task is to find these two sneaky numbers. Return an array of
11+ * size two containing the two numbers (in any order), so peace can return to Digitville.
12+ */
13+
14+ /**
15+ * @param {number[] } nums
16+ * @return {number[] }
17+ */
18+ var getSneakyNumbers = function ( nums ) {
19+ const set = new Set ( ) ;
20+ const result = [ ] ;
21+
22+ for ( const n of nums ) {
23+ if ( set . has ( n ) ) {
24+ result . push ( n ) ;
25+ } else {
26+ set . add ( n ) ;
27+ }
28+ }
29+
30+ return result ;
31+ } ;
You can’t perform that action at this time.
0 commit comments