Strictly Palindromic Number - Problem
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.
Given an integer n, return true if n is strictly palindromic and false otherwise.
A string is palindromic if it reads the same forward and backward.
Input & Output
Example 1 — Small Number
$
Input:
n = 9
›
Output:
false
💡 Note:
In base 2: 9 = 1001 (palindromic), but in base 3: 9 = 100 (not palindromic), so return false
Example 2 — Very Small Number
$
Input:
n = 4
›
Output:
false
💡 Note:
Need to check bases [2]. In base 2: 4 = 100 (not palindromic), so return false
Example 3 — Edge Case
$
Input:
n = 2
›
Output:
false
💡 Note:
No bases to check (range [2, 0] is empty), but by definition return false
Constraints
- 1 ≤ n ≤ 2 × 109
Visualization
Tap to expand
Understanding the Visualization
1
Input
Given integer n = 9
2
Process
Must check palindrome property in bases 2 through 7
3
Output
Return false - impossible to satisfy all bases
Key Takeaway
🎯 Key Insight: The constraint is mathematically impossible to satisfy for any meaningful input
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code