Skip to content

Commit ec1f12c

Browse files
authored
Create Count-Odd-Numbers-in-an-Interval-Range.py (#353)
1 parent faa66f7 commit ec1f12c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def countOdds(self, low: int, high: int) -> int:
3+
if high%2==0 and low%2==0:
4+
return (high-low)//2
5+
elif high%2==0 and low%2!=0:
6+
return (high-low)//2+1
7+
elif high%2!=0 and low%2==0:
8+
return (high-low)//2+1
9+
else:
10+
return (high-low)//2+1

0 commit comments

Comments
 (0)