1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/两数相加 II [lMSNwu].html

47 lines
1.4 KiB
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给定两个 <strong>非空链表</strong> <code>l1</code><code>l2</code>&nbsp;来代表两个非负整数。数字最高位位于链表开始位置。它们的每个节点只存储一位数字。将这两数相加会返回一个新的链表。</p>
<p>可以假设除了数字 0 之外,这两个数字都不会以零开头。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>链表的长度范围为<code> [1, 100]</code></li>
<li><code>0 &lt;= node.val &lt;= 9</code></li>
<li>输入数据保证链表代表的数字无前导 0</li>
</ul>
<p>&nbsp;</p>
<p><strong>进阶:</strong>如果输入链表不能修改该如何处理?换句话说,不能对列表中的节点进行翻转。</p>
<p>&nbsp;</p>
<p><meta charset="UTF-8" />注意:本题与主站 445&nbsp;题相同:<a href="https://leetcode-cn.com/problems/add-two-numbers-ii/">https://leetcode-cn.com/problems/add-two-numbers-ii/</a></p>