How to Solve '1550 Three Consecutive Odds' on LeetCode? - Javascript

preview_player
Показать описание
Do you need more help with coding?
════════════════════════════
════════════════════════════

Problem: #1550 Three Consecutive Odds
Language: #Javascript
Difficulty: Easy

Strategy: Traverse array and keep count
Time Complexity: O(n)
Space Complexity: O(1)

1. Create oddCount variable.
2. Loop through arr.
a. Create condition to see if current index value is odd.
i. Increment oddCount.
ii. If oddCount is equal to 3.
1. Return true.
b. Else
i. Set oddCount to 0.
3. Return false.

GitHub Repo:

Let's Connect 💯:
════════════════════════════
Рекомендации по теме
visit shbcf.ru