1468. Check If N and Its Double Exist
My accepted Python solution to LeetCode problem 1468, Check If N and Its Double Exist, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.4MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.4MB, accepted 2025-12-29.
class Solution:
def checkIfExist(self, arr: List[int]) -> bool:
# Use hash set for O(n) lookup
# Time: O(n), Space: O(n)
seen = set()
for num in arr:
if num * 2 in seen or (num % 2 == 0 and num // 2 in seen):
return True
seen.add(num)
return False