Skip to main content
Back to problems
Leetcode
Medium
Math
Combinatorics
Simulation
Count Symmetric Integers

Count how many integers in a range have an even number of digits and equal digit sums in both halves.

Acceptance 0%
Problem Statement

Given two integers low and high, count how many integers x in the inclusive range [low, high] are symmetric.

An integer is symmetric when:

  • it has an even number of digits, and
  • the sum of the first half of its digits is equal to the sum of the second half of its digits.

For example, 1230 is symmetric because 1 + 2 = 3 + 0.

Return the total number of symmetric integers in the range.

Input Format

  • Two integers low and high representing the inclusive range.
  • 1 <= low <= high.

Output Format

  • Return a single integer: the count of symmetric integers in [low, high].

Constraints

  • Only numbers with an even number of digits can be symmetric.
  • The range is inclusive.
  • A number is evaluated by its decimal representation without leading zeros.
Examples
Sample cases returned by the problem API.

Example 1

Input

low = 1, high = 100

Output

9

Explanation

The symmetric integers are 11, 22, 33, 44, 55, 66, 77, 88, and 99.

Example 2

Input

low = 1200, high = 1230

Output

4

Explanation

The symmetric integers in this range are 1203, 1212, 1221, and 1230.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.