Leetcode Note: Go - Count Odd Numbers in an Interval Range
Count Odd Numbers in an Interval Range - LeetCode
https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/
- Go 言語で取り組んだメモ
回答
Golang O(1) solution faster than 100% with explanation and images - Count Odd Numbers in an Interval Range - LeetCode
https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/solutions/1080009/golang-o-1-solution-faster-than-100-with-explanation-and-images/
func countOdds(low int, high int) int {
return (high + 1)/2 - low / 2
}