Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.01 KB

_2843. Count Symmetric Integers.md

File metadata and controls

41 lines (30 loc) · 1.01 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : April 11, 2025

Last updated : April 11, 2025


Related Topics : Math, Enumeration

Acceptance Rate : 83.14 %


Solutions

Python

class Solution:
    def countSymmetricIntegers(self, low: int, high: int) -> int:
        output = 0
        helper = (lambda x: sum(map(int, x[:len(x) // 2])) == sum(map(int, x[len(x) // 2:])))
        while low <= high :
            if len(str(low)) % 2 == 1 :
                low = 10 ** ceil(log(low + 1, 10))
                continue
            if helper(str(low)) :
                output += 1
            low += 1
        return output