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)/连续差相同的数字 [numbers-with-same-consecutive-differences].html
2022-03-29 12:43:11 +08:00

45 lines
1.3 KiB
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>返回所有长度为 <code>n</code> 且满足其每两个连续位上的数字之间的差的绝对值为 <code>k</code><strong> 非负整数 </strong></p>
<p>请注意,<strong>除了 </strong>数字 <code>0</code> 本身之外,答案中的每个数字都 <strong>不能 </strong>有前导零。例如,<code>01</code> 有一个前导零,所以是无效的;但 <code>0</code>&nbsp;是有效的。</p>
<p>你可以按 <strong>任何顺序</strong> 返回答案。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 3, k = 7
<strong>输出:</strong>[181,292,707,818,929]
<strong>解释:</strong>注意070 不是一个有效的数字,因为它有前导零。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 2, k = 1
<strong>输出:</strong>[10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>n = 2, k = 0
<strong>输出:</strong>[11,22,33,44,55,66,77,88,99]
</pre>
<p><strong>示例 4</strong></p>
<pre>
<strong>输入:</strong>n = 2, k = 2
<strong>输出:</strong>[13,20,24,31,35,42,46,53,57,64,68,75,79,86,97]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= n &lt;= 9</code></li>
<li><code>0 &lt;= k &lt;= 9</code></li>
</ul>