Check If N and Its Double Exist

Given an array arr of integers, check if there exist two indices i and j such that:

• i != j
• 0 <= i, j < arr.length
• arr[i] == 2 * arr[j]

Example 1:

```Input: arr = [10,2,5,3]
Output: true
Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]
```

Example 2:

```Input: arr = [3,1,7,11]
Output: false
Explanation: There is no i and j that satisfy the conditions.
```

Constraints:

• 2 <= arr.length <= 500
• -103 <= arr[i] <= 103

思路和解题步骤（中文）：

1. 初始化: 创建一个哈希集合（HashSet）来存储数组中的每个元素，以便快速检查某个数或其两倍是否存在。
2. 遍历数组: 遍历给定的整数数组。对于每个元素 `n`，我们做以下操作：
• 检查 `n` 的两倍或 `n / 2`（当 `n` 是偶数时）是否在哈希集合中。如果是，返回 `true`，因为我们找到了满足条件的一对数。
• `n` 添加到哈希集合中，以供后续查找。
3. 返回结果: 如果整个数组都遍历完毕，没有找到符合条件的数对，则返回 `false`

Thought Process and Steps (English):

1. Initialization: Create a hash set to store each element of the array for quick checking whether a number or its double exists.
2. Traverse the Array: Iterate through the given integer array. For each element `n`, we do the following:
• Check if the double of `n` or `n / 2` (when `n` is even) exists in the hash set. If yes, return `true` as we have found a pair satisfying the condition.
• Add `n` to the hash set for future lookup.
3. Return the Result: If we have traversed the entire array without finding any satisfying pair, then return `false`.

``````function checkIfExist(arr: number[]): boolean {
const seen: Set<number> = new Set();
for (const num of arr) {
if (seen.has(2 * num) || (num % 2 === 0 && seen.has(num / 2))) {
return true;
}