Class Solution
-
- All Implemented Interfaces:
public final class Solution
2396 - Strictly Palindromic Number\.
Medium
An integer
n
is strictly palindromic if, for every baseb
between2
andn - 2
( inclusive ), the string representation of the integern
in baseb
is palindromic.Given an integer
n
, returntrue
ifn
is strictly palindromic andfalse
otherwise.A string is palindromic if it reads the same forward and backward.
Example 1:
Input: n = 9
Output: false
Explanation: In base 2: 9 = 1001 (base 2), which is palindromic.
In base 3: 9 = 100 (base 3), which is not palindromic.
Therefore, 9 is not strictly palindromic so we return false.
Note that in bases 4, 5, 6, and 7, n = 9 is also not palindromic.
Example 2:
Input: n = 4
Output: false
Explanation: We only consider base 2: 4 = 100 (base 2), which is not palindromic.
Therefore, we return false.
Constraints:
<code>4 <= n <= 10<sup>5</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final Boolean
isStrictlyPalindromic(Integer n)
-
-
Method Detail
-
isStrictlyPalindromic
final Boolean isStrictlyPalindromic(Integer n)
-
-
-
-