Skip to content

Commit 54e99f8

Browse files
committedApr 11, 2025
Add solution #1346
1 parent 9dece44 commit 54e99f8

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
 

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,245 LeetCode solutions in JavaScript
1+
# 1,246 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1022,6 +1022,7 @@
10221022
1343|[Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold](./solutions/1343-number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold.js)|Medium|
10231023
1344|[Angle Between Hands of a Clock](./solutions/1344-angle-between-hands-of-a-clock.js)|Medium|
10241024
1345|[Jump Game IV](./solutions/1345-jump-game-iv.js)|Hard|
1025+
1346|[Check If N and Its Double Exist](./solutions/1346-check-if-n-and-its-double-exist.js)|Easy|
10251026
1351|[Count Negative Numbers in a Sorted Matrix](./solutions/1351-count-negative-numbers-in-a-sorted-matrix.js)|Easy|
10261027
1352|[Product of the Last K Numbers](./solutions/1352-product-of-the-last-k-numbers.js)|Medium|
10271028
1356|[Sort Integers by The Number of 1 Bits](./solutions/1356-sort-integers-by-the-number-of-1-bits.js)|Easy|
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* 1346. Check If N and Its Double Exist
3+
* https://leetcode.com/problems/check-if-n-and-its-double-exist/
4+
* Difficulty: Easy
5+
*
6+
* Given an array arr of integers, check if there exist two indices i and j such that:
7+
* - i != j
8+
* - 0 <= i, j < arr.length
9+
* - arr[i] == 2 * arr[j]
10+
*/
11+
12+
/**
13+
* @param {number[]} arr
14+
* @return {boolean}
15+
*/
16+
var checkIfExist = function(arr) {
17+
const set = new Set();
18+
19+
for (const num of arr) {
20+
if (set.has(num * 2) || set.has(num / 2)) {
21+
return true;
22+
}
23+
set.add(num);
24+
}
25+
26+
return false;
27+
};

0 commit comments

Comments
 (0)
Please sign in to comment.