Skip to content

Commit b05d40d

Browse files
committed
Runtime: 1302 ms (Top 45.3%) | Memory: 13.61 MB (Top 27.6%)
1 parent 47b679c commit b05d40d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Runtime: 1302 ms (Top 45.3%) | Memory: 13.61 MB (Top 27.6%)
2+
3+
class Solution(object):
4+
def countSymmetricIntegers(self, low, high):
5+
"""
6+
:type low: int
7+
:type high: int
8+
:rtype: int
9+
"""
10+
all = 0
11+
# This counts the total number of symmetrical integers
12+
for i in range(low, high+1):
13+
# Loop through every possible number
14+
i = str(i)
15+
# Convert the number to a string
16+
if len(i) % 2 == 0:
17+
# Check that there is an even number of digits
18+
if sum([int(i[x]) for x in range(0, len(i)/2)]) == sum([int(i[x]) for x in range(len(i)/2, len(i))]):
19+
# Compare the first and last half of the string
20+
all += 1
21+
return all
22+
# Return the final answer
23+

0 commit comments

Comments
 (0)