boolpal(int r){ string s = to_string(r); int i = 0, j = s.length() - 1; while(i < j) { if(s[i] != s[j]) returnfalse; i++,j--; } returntrue; } intSolution::solve(int A, int B, int C){ int res = 0, now = 0, l = A, r = A; while(r < B) { while(r <= B and r - l <= C) { if(pal(r)) now++; if(r - l <= C) res = max(res, now); r++; } while(l < r and r - l > C) { if(pal(l)) now--; l++; } } return res; }