Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 59e5d61

Browse files
Add solution for Three Consecutive Odds problem with implementation
1 parent 740d2c6 commit 59e5d61

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- https://leetcode.com/problems/contains-duplicate/
2626
- https://leetcode.com/problems/contains-duplicate-ii/description/
2727
- https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/
28+
- https://leetcode.com/problems/three-consecutive-odds/description/?envType=daily-question&envId=2025年05月11日
2829

2930

3031

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Easy: https://leetcode.com/problems/three-consecutive-odds/description/?envType=daily-question&envId=2025年05月11日
2+
class Solution {
3+
bool threeConsecutiveOdds(List<int> arr) {
4+
int oddsNumber = 0;
5+
for (int i = 0; i < arr.length; i++) {
6+
if (arr[i] % 2 == 1) {
7+
++oddsNumber;
8+
} else {
9+
oddsNumber = 0;
10+
}
11+
12+
if (oddsNumber == 3) {
13+
return true;
14+
}
15+
}
16+
return false;
17+
}
18+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /