Skip to content

Commit fb56d5f

Browse files
committed
Add solution #3289
1 parent eff5acd commit fb56d5f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,6 +2695,7 @@
26952695
3272|[Find the Count of Good Integers](./solutions/3272-find-the-count-of-good-integers.js)|Hard|
26962696
3279|[Maximum Total Area Occupied by Pistons](./solutions/3279-maximum-total-area-occupied-by-pistons.js)|Hard|
26972697
3284|[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|
26982699
3294|[Convert Doubly Linked List to Array II](./solutions/3294-convert-doubly-linked-list-to-array-ii.js)|Medium|
26992700
3299|[Sum of Consecutive Subsequences](./solutions/3299-sum-of-consecutive-subsequences.js)|Hard|
27002701
3304|[Find the K-th Character in String Game I](./solutions/3304-find-the-k-th-character-in-string-game-i.js)|Easy|
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
};

0 commit comments

Comments
 (0)