Leetcode 1468 Solution

This article provides solution to leetcode question 1468 (check-if-n-and-its-double-exist)

https://leetcode.com/problems/check-if-n-and-its-double-exist

Solution

class Solution:
    def checkIfExist(self, arr: List[int]) -> bool:
        m = collections.defaultdict(int)

        for ele in arr:
            m[ele] += 1

        for ele in arr:
            if ele == 0:
                if ele in m and m[ele] >= 2:
                    return True
            else:
                if 2 * ele in m:
                    return True

        return False