Ctrl K

The Odd Side of the Street

Easy
A mail carrier visits the houses numbered from first to last, inclusive. Odd-numbered houses stand on one side of the street and even-numbered ones on the other. How many of these houses are on the odd side? Return that count.
Example 1
first=4, last=11 → 4

The odd numbers are 5, 7, 9 and 11, so four houses.

Example 2
first=6, last=6 → 0

The only house, number 6, is on the even side.

Example 3
first=0, last=3 → 2

Numbers 1 and 3 qualify.

Constraints
  • 0 ≤ first ≤ last ≤ 2·10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Number That Reads Both Ways EasyValue of a Roman Numeral EasyAdd One to a Digit Array EasySum of Binary Strings EasyWhole Square Root Easy
loading Python…
Input
first=4, last=11
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.