Leetcode Problem 1550. Three Consecutive Odds

1550. Three Consecutive Odds

Leetcode Solutions

Iterative Check for Consecutive Odds

  1. Check if the array length is less than 3. If so, return false because we need at least three numbers to have three consecutive odds.
  2. Iterate through the array starting from the third element (index 2).
  3. For each element at index i, check if arr[i], arr[i-1], and arr[i-2] are all odd.
  4. If they are all odd, return true.
  5. If the loop completes without finding three consecutive odds, return false.
UML Thumbnail

Counting Consecutive Odds

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...