mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<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> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> n = 9
 | 
						|
<strong>Output:</strong> false
 | 
						|
<strong>Explanation:</strong> 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.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> n = 4
 | 
						|
<strong>Output:</strong> false
 | 
						|
<strong>Explanation:</strong> We only consider base 2: 4 = 100 (base 2), which is not palindromic.
 | 
						|
Therefore, we return false.
 | 
						|
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>4 <= n <= 10<sup>5</sup></code></li>
 | 
						|
</ul>
 |