↓Skip to main content
  1. LeetCode/

LeetCode 1550: Three Consecutive Odds

·1 min· ·
LeetCode Easy Array
Wei Yi Chung
Author
Wei Yi Chung
Working at the contributing of open source, distributed systems, and data engineering.
Table of Contents

Meta Data
#

Difficulty: easy First Attempt: 2025-05-11

  • Total time: 05:00.00

Intuition
#

Set a counter to track the number of consecutive odd numbers.
If the count reaches 3, return the result early.

Approach
#

class Solution:
    def threeConsecutiveOdds(self, arr: List[int]) -> bool:
        
        count = 0
        for num in arr:
            if num%2:
                count+=1
            else:
                count = 0

            if count == 3:
                return True

        return False

Findings
#

Encountered Problems
#

Related

LeetCode 1920: Build Array from Permutation
·1 min
LeetCode Easy Array Simulation
LeetCode 1920 note: follow the definition ans[i] = nums[nums[i]]; for O(1) extra space, stack the new value times n on top of the old one
LeetCode 2176: Count Equal and Divisible Pairs in an Array
·1 min
LeetCode Easy Array
LeetCode 2176 note: n is only 100, so enumerate all pairs; the condition is equal values and the index product i * j divisible by k
LeetCode 3507: Minimum Pair Removal to Sort Array I
·2 mins
LeetCode Easy Simulation Array
LeetCode 3507 note: n is tiny, so simulate; the right side of a slice assignment must be a list
LeetCode 1431: Kids With the Greatest Number of Candies
·1 min
LeetCode Easy Array
LeetCode 1431 note: compute the maximum once; a kid is True when their candies plus the extra reach >= the maximum, since a tie counts
LeetCode 3487: Maximum Unique Subarray Sum After Deletion
·2 mins
LeetCode Easy Greedy Hash-Table Array
LeetCode 3487 note: free deletion means picking distinct values; take every non-negative one, or only the maximum when all are negative
LeetCode 3131: Find the Integer Added to Array I
·1 min
LeetCode Easy Array
LeetCode 3131 note: every element gets the same x, so x is the difference of the two minimums (or of the sums divided by the length)