Three Consecutive Odds asks whether an integer array contains three odd numbers in a row, returning true if such a consecutive sequence exists and false otherwise.
Statement
Given an integer array arr, return true if there are 3 consecutive odd numbers in the array, and false otherwise.
Constraints:
1≤arr.length≤1000
1≤arr[i]≤1000
Examples
Fetching Slides...
Understand the problem
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Three Consecutive Odds
1.
For the input arr = [7], what should the function return?
A.
true because a single odd number is enough
B.
false because there are not (3) consecutive odd numbers
C.
true because (7) is odd and the array has length (1)
D.
false because the array contains no even numbers
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence
1
2
3
4
5
Try it yourself
Implement your solution in the following coding playground.
Three Consecutive Odds asks whether an integer array contains three odd numbers in a row, returning true if such a consecutive sequence exists and false otherwise.
Statement
Given an integer array arr, return true if there are 3 consecutive odd numbers in the array, and false otherwise.
Constraints:
1≤arr.length≤1000
1≤arr[i]≤1000
Examples
Fetching Slides...
Understand the problem
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Three Consecutive Odds
1.
For the input arr = [7], what should the function return?
A.
true because a single odd number is enough
B.
false because there are not (3) consecutive odd numbers
C.
true because (7) is odd and the array has length (1)
D.
false because the array contains no even numbers
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence
1
2
3
4
5
Try it yourself
Implement your solution in the following coding playground.