<p>You are given two positive integers <code>low</code> and <code>high</code>.</p>

<p>An integer <code>x</code> consisting of <code>2 * n</code> digits is <strong>symmetric</strong> if the sum of the first <code>n</code> digits of <code>x</code> is equal to the sum of the last <code>n</code> digits of <code>x</code>. Numbers with an odd number of digits are never symmetric.</p>

<p>Return <em>the <strong>number of symmetric</strong> integers in the range</em> <code>[low, high]</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> low = 1, high = 100
<strong>Output:</strong> 9
<strong>Explanation:</strong> There are 9 symmetric integers between 1 and 100: 11, 22, 33, 44, 55, 66, 77, 88, and 99.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> low = 1200, high = 1230
<strong>Output:</strong> 4
<strong>Explanation:</strong> There are 4 symmetric integers between 1200 and 1230: 1203, 1212, 1221, and 1230.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= low &lt;= high &lt;= 10<sup>4</sup></code></li>
</ul>

from typing import List, Optional

class Solution:
    # symmetric list + add the first entries
    nums: List = [11, 22, 33, 44, 55, 66, 77, 88, 99]

    #helper
    def issymetrical(self, s: str) -> int:
        return int(s[-1]) + int(s[-2]) == int(s[0]) + int(s[1])
    #dp function
    def build_out(self, low: int, high: int) -> None:
        for i in range(max(low,100), high+1):
            if self.issymetrical(str(i)) and len(str(i)) != 3:
                if i not in self.nums:
                    print(i)
                    self.nums.append(i)
    
    #actual comparison
    def countSymmetricIntegers(self, low: int, high: int) -> int:
        counter: int = 0
        
        #build out further if high is higher than last in nums
        if high > self.nums[-1]:
            self.build_out(low, high)

        for i in self.nums:
            if low <= i <= high:
                counter += 1
                
        return counter

    # =========================================================

def main() -> None:

    low: int = 100
    high:int = 1782

    sol: Solution = Solution()
    print(sol.countSymmetricIntegers(low,high))

if __name__ == "__main__":
    main()

# =========================================================
96