java.lang.Object
g2301_2400.s2396_strictly_palindromic_number.Solution

public class Solution extends Object
2396 - Strictly Palindromic Number.<p>Medium</p> <p>An integer <code>n</code> is <strong>strictly palindromic</strong> if, for <strong>every</strong> base <code>b</code> between <code>2</code> and <code>n - 2</code> ( <strong>inclusive</strong> ), the string representation of the integer <code>n</code> in base <code>b</code> is <strong>palindromic</strong>.</p> <p>Given an integer <code>n</code>, return <code>true</code> <em>if</em> <code>n</code> <em>is <strong>strictly palindromic</strong> and</em> <code>false</code> <em>otherwise</em>.</p> <p>A string is <strong>palindromic</strong> if it reads the same forward and backward.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 9</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> In base 2: 9 = 1001 (base 2), which is palindromic.</p> <p>In base 3: 9 = 100 (base 3), which is not palindromic.</p> <p>Therefore, 9 is not strictly palindromic so we return false.</p> <p>Note that in bases 4, 5, 6, and 7, n = 9 is also not palindromic.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 4</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> We only consider base 2: 4 = 100 (base 2), which is not palindromic.</p> <p>Therefore, we return false.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>4 <= n <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • isStrictlyPalindromic

      public boolean isStrictlyPalindromic(int n)