Skip to content

Commit e9d0b99

Browse files
Update 1523. Count Odd Numbers in an Interval Range.py
Added function comment and inline comments
1 parent ae32cc6 commit e9d0b99

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Solution(object):
22
def countOdds(self, low, high):
3-
"""
4-
:type low: int
5-
:type high: int
6-
:rtype: int
7-
"""
8-
3+
"""
4+
countOdds takes low (int) and high (int) as inputs and returns the count of odd numbers within the range
5+
low: int
6+
high: int
7+
0 <= low <= high <= 10^9
8+
"""
99
if low % 2 == 1 or high % 2 == 1:
10-
return (high-low) / 2 + 1
10+
return (high-low) / 2 + 1 #if low or high are odd divide difference by 2 and add 1
1111
else:
12-
return (high-low) / 2
12+
return (high-low) / 2 #if low and high are even divide difference by 2

0 commit comments

Comments
 (0)