Skip to content

Commit 810580d

Browse files
committed
Add solution #1550
1 parent 0071f79 commit 810580d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
1496|[Path Crossing](./1496-path-crossing.js)|Easy|
179179
1502|[Can Make Arithmetic Progression From Sequence](./1502-can-make-arithmetic-progression-from-sequence.js)|Easy|
180180
1507|[Reformat Date](./1507-reformat-date.js)|Easy|
181+
1550|[Three Consecutive Odds](./1550-three-consecutive-odds.js)|Easy|
181182
1598|[Crawler Log Folder](./1598-crawler-log-folder.js)|Easy|
182183
1780|[Check if Number is a Sum of Powers of Three](./1780-check-if-number-is-a-sum-of-powers-of-three.js)|Medium|
183184
1880|[Check if Word Equals Summation of Two Words](./1880-check-if-word-equals-summation-of-two-words.js)|Easy|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* 1550. Three Consecutive Odds
3+
* https://leetcode.com/problems/three-consecutive-odds/
4+
* Difficulty: Easy
5+
*
6+
* Given an integer array arr, return true if there are three consecutive odd
7+
* numbers in the array. Otherwise, return false.
8+
*/
9+
10+
/**
11+
* @param {number[]} arr
12+
* @return {boolean}
13+
*/
14+
var threeConsecutiveOdds = function(arr) {
15+
for (let i = 0, count = 0; i < arr.length; i++) {
16+
count = arr[i] % 2 !== 0 ? count + 1 : 0;
17+
if (count === 3) return true;
18+
}
19+
return false;
20+
};

0 commit comments

Comments
 (0)