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)/链表中的两数相加 [lMSNwu].html
2022-03-29 12:43:11 +08:00

47 lines
1.4 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> <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>