Skip to content

Commit 95a2065

Browse files
committed
Apr 11
1 parent 9d9e2b9 commit 95a2065

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class Solution:
2+
def __is_symmetric(self, num: int) -> bool:
3+
if num < 10:
4+
return False
5+
if num < 100:
6+
d1 = num % 10
7+
d2 = num // 10
8+
return d1 == d2
9+
if num < 1_000:
10+
return False
11+
if num < 10_000:
12+
d1 = num % 10
13+
num //= 10
14+
d2 = num % 10
15+
num //= 10
16+
d3 = num % 10
17+
num //= 10
18+
d4 = num % 10
19+
return d1 + d2 == d3 + d4
20+
return False
21+
22+
def countSymmetricIntegers(self, low: int, high: int) -> int:
23+
return sum(map(self.__is_symmetric, range(low, high+1)))
24+
25+
26+
def main():
27+
low = 1
28+
high = 100
29+
assert Solution().countSymmetricIntegers(low, high) == 9
30+
31+
low = 1200
32+
high = 1230
33+
assert Solution().countSymmetricIntegers(low, high) == 4
34+
35+
36+
if __name__ == '__main__':
37+
main()

2025-04-April-LeetCoding-Challenge/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
| April 07 | [416. Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/) | Medium | Solved |
1414
| April 08 | [3396. Minimum Number of Operations to Make Elements in Array Distinct](https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/) | Easy | Solved |
1515
| April 09 | [3375. Minimum Operations to Make Array Values Equal to K](https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/) | Easy | Solved |
16-
| April 10 | []() | | |
17-
| April 11 | []() | | |
16+
| April 10 | [2999. Count the Number of Powerful Integers](https://leetcode.com/problems/count-the-number-of-powerful-integers/) | Hard | Unsolved |
17+
| April 11 | [2843. Count Symmetric Integers](https://leetcode.com/problems/count-symmetric-integers/) | Easy | Solved |
1818
| April 12 | []() | | |
1919
| April 13 | []() | | |
2020
| April 14 | []() | | |
@@ -39,6 +39,6 @@
3939
## Summary
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
42-
| Easy | 3 | 3 | 0 |
42+
| Easy | 4 | 4 | 0 |
4343
| Medium | 6 | 5 | 1 |
44-
| Hard | 0 | 0 | 0 |
44+
| Hard | 1 | 0 | 1 |

0 commit comments

Comments
 (0)