2180. Count Integers With Even Digit Sum
On This Page
class Solution:
def countEven(self, num: int) -> int:
res = num // 10 * 5 - 1
x, s = num // 10, 0
while x:
s += x % 10
x //= 10
res += (num % 10 + 2 - (s & 1)) >> 1
return res