Practice Three Consecutive Odds
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return true if arr contains three adjacent entries that are all odd; otherwise return false. The entries must be consecutive positions, but their numeric values need not be consecutive integers. Practice approach: Keep a running count of adjacent odd entries. Increment it for an odd value and reset it for an even value. Return true as soon as the count reaches three. This scans at most n elements in O(n) time and O(1) extra space. Arrays shorter than three cannot qualify; an even entry breaks the streak.
Source: Three Consecutive Odds on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
arr = [2,6,4,1]
false
# Example 2
arr = [1,2,34,3,4,5,7,23,12]
true
Constraints
Related LeetCode Problems
Practice more problems similar to Three Consecutive Odds.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.