Skip to content

Commit 9dfb068

Browse files
authored
Update Solution.cpp
1 parent 2ff611a commit 9dfb068

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

solution/1500-1599/1550.Three Consecutive Odds/Solution.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ class Solution {
22
public:
33
bool threeConsecutiveOdds(vector<int>& arr) {
44
int cnt = 0;
5-
for (int v : arr) {
6-
if (v & 1)
7-
++cnt;
8-
else
5+
for (int x : arr) {
6+
if (x & 1) {
7+
if (++cnt == 3) {
8+
return true;
9+
}
10+
} else {
911
cnt = 0;
10-
if (cnt == 3) return true;
12+
}
1113
}
1214
return false;
1315
}
14-
};
16+
};

0 commit comments

Comments
 (0)