2180. Count Integers With Even Digit Sum

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2180

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