547.Count Palindromic Numbers in a Range
Easy
Given a range
low to high (inclusive), return how many numbers in it are palindromes — numbers that read the same forwards and backwards, like 7, 44 or 12321.
Checking one number is the job of an isPalindrome(n) helper; counting across a range is the job of the main function. Keeping those two jobs apart is the core idea of separation of concernsSeparation of ConcernsGiving each function one clear responsibility, so it can be understood, tested and changed on its own.: the two solutions swap in completely different helpers, and the counting loop does not change by a single character.
Example 1:
Input: low = 1, high = 20
Output: 10
Example 2:
Input: low = 100, high = 130
Output: 3
+ 5 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ low ≤ high ≤ 100000
low =
1
high =
20