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)/两数相加 [add-two-numbers].html

40 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>给你两个&nbsp;<strong>非空</strong> 的链表,表示两个非负的整数。它们每位数字都是按照&nbsp;<strong>逆序</strong>&nbsp;的方式存储的,并且每个节点只能存储&nbsp;<strong>一位</strong>&nbsp;数字。</p>
<p>请你将两个数相加,并以相同形式返回一个表示和的链表。</p>
<p>你可以假设除了数字 0 之外,这两个数都不会以 0&nbsp;开头。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/01/02/addtwonumber1.jpg" style="width: 483px; height: 342px;" />
<pre>
<strong>输入:</strong>l1 = [2,4,3], l2 = [5,6,4]
<strong>输出:</strong>[7,0,8]
<strong>解释:</strong>342 + 465 = 807.
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>l1 = [0], l2 = [0]
<strong>输出:</strong>[0]
</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<strong>输入:</strong>l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
<strong>输出:</strong>[8,9,9,9,0,0,0,1]
</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>题目数据保证列表表示的数字不含前导零</li>
</ul>