1346. 检查整数及其两倍数是否存在




代码一

class Solution(object):
    def checkIfExist(self, arr):
        """
        :type arr: List[int]
        :rtype: bool
        """
        if not arr:
            return True
        if arr.count(0) > 1:
            return True
        for item in arr:
            if item == 0:
                continue
            if 2 * item in arr:
                return True
        return False

代码二

class Solution(object):
    def checkIfExist(self, arr):
        """
        :type arr: List[int]
        :rtype: bool
        """
        for i, a in enumerate(arr):
            for j, b in enumerate(arr):
                if i != j and a*2 == b:
                    return True
        return False
原文地址:https://www.cnblogs.com/panweiwei/p/13754582.html