leetcode--python--1550

1550. There are three consecutive odd arrays

Give you an integer array arr, please judge whether there are three consecutive elements in the array that are all odd numbers: if it exists, please return true; otherwise, return false

Solution: The multiplication of three odd numbers is still odd, and the multiplication of arbitrary numbers and even numbers is still even

class Solution:
    def threeConsecutiveOdds(self, arr: List[int]) -> bool:
        for i in range(len(arr) - 2):
            mut = arr[i] * arr[i+1] * arr[i+2]
            if mut%2 != 0:
                return(True)
        return(False)

Guess you like

Origin blog.csdn.net/AWhiteDongDong/article/details/110863643