This commit is contained in:
parent
87d3129bde
commit
6a2a68ee17
1 changed files with 16 additions and 0 deletions
16
easy/check_if_n_and_its_double_exist.py
Normal file
16
easy/check_if_n_and_its_double_exist.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# https://leetcode.com/problems/check-if-n-and-its-double-exist
|
||||
|
||||
from typing import List
|
||||
|
||||
class Solution:
|
||||
def checkIfExist(self, arr: List[int]) -> bool:
|
||||
m = {key: True for key in arr}
|
||||
i_count = 0
|
||||
for i in arr:
|
||||
if i == 0:
|
||||
i_count += 1
|
||||
continue
|
||||
if i * 2 in m:
|
||||
return True
|
||||
return True if i_count > 1 else False
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue