Skip to content

Commit 9dafea2

Browse files
authored
Update count-hills-and-valleys-in-an-array.cpp
1 parent f6b465f commit 9dafea2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

C++/count-hills-and-valleys-in-an-array.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class Solution {
88
int result = 0, inc = -1;
99
for (int i = 0; i + 1 < size(nums); ++i) {
1010
if (nums[i] < nums[i + 1]) {
11-
result += (inc == 0) ? 1 : 0;
11+
result += static_cast<int>(inc == 0);
1212
inc = 1;
1313
} else if (nums[i] > nums[i + 1]) {
14-
result += (inc == 1) ? 1 : 0;
14+
result += static_cast<int>(inc == 1);
1515
inc = 0;
1616
}
1717
}

0 commit comments

Comments
 (0)