lc-go/solutions/15/q1523/solution.go

14 lines
292 B
Go

// Package q1523 implements a solution for https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/
package q1523
func countOdds(low int, high int) int {
if low%2 == 1 {
low -= 1
}
if high%2 == 1 {
return (high-low)/2 + 1
}
return (high - low) / 2
}
var _ = countOdds