1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/寻找最近的回文数 [find-the-closest-palindrome].html
2022-03-29 12:43:11 +08:00

32 lines
902 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个表示整数的字符串&nbsp;<code>n</code> ,返回与它最近的回文整数(不包括自身)。如果不止一个,返回较小的那个。</p>
<p>“最近的”定义为两个整数<strong>差的绝对值</strong>最小。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong> n = "123"
<strong>输出:</strong> "121"
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> n = "1"
<strong>输出:</strong> "0"
<strong>解释:</strong> 0 和 2是最近的回文但我们返回最小的也就是 0。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n.length &lt;= 18</code></li>
<li><code>n</code>&nbsp;只由数字组成</li>
<li><code>n</code>&nbsp;不含前导 0</li>
<li><code>n</code>&nbsp;代表在&nbsp;<code>[1, 10<sup>18</sup>&nbsp;- 1]</code> 范围内的整数</li>
</ul>