Leetcode Note: Go - Three Consecutive Odds

Three Consecutive Odds - LeetCode
https://leetcode.com/problems/three-consecutive-odds/

  • Go 言語で取り組んだメモ

回答

Go Solution - Three Consecutive Odds - LeetCode
https://leetcode.com/problems/three-consecutive-odds/solutions/794992/go-solution/

func threeConsecutiveOdds(arr []int) bool {
    sz := len(arr)

    if sz < 3 {return false}

    for i, _ := range arr {
        if i + 2 < sz {
            if arr[i] % 2 != 0 && arr[i + 1] % 2 != 0 && arr[i + 2] % 2 != 0 {
                return true
            }
        }
    }

    return false
}