Skip to content

Commit 85f857f

Browse files
solvesthree consecutive odds
1 parent 2530094 commit 85f857f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,4 @@
389389
| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets) | [![Java](assets/java.png)](src/CountGoodTriplets.java) | |
390390
| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number) | [![Java](assets/java.png)](src/KthMissingPositiveNumber.java) | |
391391
| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great) | [![Java](assets/java.png)](src/MakeTheStringGreat.java) | |
392+
| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds) | [![Java](assets/java.png)](src/ThreeConsecutiveOdds.java) | |

src/ThreeConsecutiveOdds.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class ThreeConsecutiveOdds {
2+
public boolean threeConsecutiveOdds(int[] array) {
3+
for (int i = 0 ; i < array.length - 2 ; i++) {
4+
if (isOdd(array[i]) && isOdd(array[i + 1]) && isOdd(array[i + 2])) {
5+
return true;
6+
}
7+
}
8+
return false;
9+
}
10+
11+
private boolean isOdd(int x) {
12+
return (x & 1) == 1;
13+
}
14+
}

0 commit comments

Comments
 (0)