Skip to content

Commit e3f2d1c

Browse files
committed
🟢 Solve problem 1550
1 parent 4615223 commit e3f2d1c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎swift/1550.swift‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
func threeConsecutiveOdds(_ arr: [Int]) -> Bool {
3+
var oddTimes = 0
4+
5+
for value in arr {
6+
if isOdd(value) {
7+
oddTimes += 1
8+
if oddTimes == 3 {
9+
return true
10+
}
11+
}
12+
13+
if !isOdd(value) {
14+
oddTimes = 0
15+
}
16+
}
17+
18+
return false
19+
}
20+
21+
private func isOdd(_ value: Int) -> Bool {
22+
return value % 2 != 0
23+
}
24+
}

0 commit comments

Comments
 (0)