From 6a2a68ee173c9de6fdf88624b1204bbb1896e800 Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Sun, 1 Dec 2024 20:40:35 +0900 Subject: [PATCH] https://leetcode.com/problems/check-if-n-and-its-double-exist --- easy/check_if_n_and_its_double_exist.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 easy/check_if_n_and_its_double_exist.py diff --git a/easy/check_if_n_and_its_double_exist.py b/easy/check_if_n_and_its_double_exist.py new file mode 100644 index 0000000..d2da00d --- /dev/null +++ b/easy/check_if_n_and_its_double_exist.py @@ -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 +