mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
43 lines
1.1 KiB
HTML
43 lines
1.1 KiB
HTML
<p>给你两个 <strong>非空 </strong>链表来代表两个非负整数。数字最高位位于链表开始位置。它们的每个节点只存储一位数字。将这两数相加会返回一个新的链表。</p>
|
||
|
||
<p>你可以假设除了数字 0 之外,这两个数字都不会以零开头。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例1:</strong></p>
|
||
|
||
<p><img alt="" src="https://pic.leetcode-cn.com/1626420025-fZfzMX-image.png" style="width: 302px; " /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>l1 = [7,2,4,3], l2 = [5,6,4]
|
||
<strong>输出:</strong>[7,8,0,7]
|
||
</pre>
|
||
|
||
<p><strong>示例2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>l1 = [2,4,3], l2 = [5,6,4]
|
||
<strong>输出:</strong>[8,0,7]
|
||
</pre>
|
||
|
||
<p><strong>示例3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>l1 = [0], l2 = [0]
|
||
<strong>输出:</strong>[0]
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li>链表的长度范围为<code> [1, 100]</code></li>
|
||
<li><code>0 <= node.val <= 9</code></li>
|
||
<li>输入数据保证链表代表的数字无前导 0</li>
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>进阶:</strong>如果输入链表不能翻转该如何解决?</p>
|