Skip to content

Commit 3919a27

Browse files
my solution to problem 1550
1 parent 360043d commit 3919a27

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

problems/1550/jeremy.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# [Problem 1550: Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds/description/)
2+
3+
## Initial thoughts (stream-of-consciousness)
4+
- This seems easy. I'll keep a running count of consecutive odds. If an even number is encountered, reset the counter. If the counter hits 3, return True. At the end of the list (if the counter has not yet hit 3), return False.
5+
6+
## Attempted solution(s)
7+
```python
8+
class Solution:
9+
def threeConsecutiveOdds(self, arr: List[int]) -> bool:
10+
counter = 0
11+
for x in arr:
12+
if x %2 == 0:
13+
counter = 0
14+
else:
15+
counter += 1
16+
if counter == 3:
17+
return True
18+
return False
19+
```
20+
- The given test cases pass; the problem is also too simply to have tricky cases
21+
- Submitting...
22+
23+
<img width="657" alt="Screenshot 2024-07-05 at 7 50 37 PM" src="https://github.com/ContextLab/leetcode-solutions/assets/9030494/dfd800db-f1c0-4cc1-8f8e-a02f75521656">
24+
25+
Problem solved!

0 commit comments

Comments
 (0)