We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a781f97 commit f9a56e2Copy full SHA for f9a56e2
C++/count-odd-numbers-in-an-interval-range.cpp
@@ -0,0 +1,9 @@
1
+// Time: O(n)
2
+// Space: O(1)
3
+
4
+class Solution {
5
+public:
6
+ int countOdds(int low, int high) {
7
+ return (high + 1) / 2 - ((low - 1) + 1) / 2;
8
+ }
9
+};
0 commit comments