1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 23:41:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/加一 [plus-one].html
2025-01-09 20:29:41 +08:00

43 lines
1.1 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>给定一个由 <strong>整数 </strong>组成的<strong> 非空</strong> 数组所表示的非负整数,在该数的基础上加一。</p>
<p>最高位数字存放在数组的首位, 数组中每个元素只存储<strong>单个</strong>数字。</p>
<p>你可以假设除了整数 0 之外,这个整数不会以零开头。</p>
<p>&nbsp;</p>
<p><strong>示例&nbsp;1</strong></p>
<pre>
<strong>输入:</strong>digits = [1,2,3]
<strong>输出:</strong>[1,2,4]
<strong>解释:</strong>输入数组表示数字 123。
</pre>
<p><strong>示例&nbsp;2</strong></p>
<pre>
<strong>输入:</strong>digits = [4,3,2,1]
<strong>输出:</strong>[4,3,2,2]
<strong>解释:</strong>输入数组表示数字 4321。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>digits = [9]
<strong>输出:</strong>[1,0]
<strong>解释:</strong>输入数组表示数字 9。
加 1 得到了 9 + 1 = 10。
因此,结果应该是 [1,0]。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= digits.length &lt;= 100</code></li>
<li><code>0 &lt;= digits[i] &lt;= 9</code></li>
</ul>