Q2: Add Two Numbers
Last updated
Was this helpful?
Last updated
Was this helpful?
直达:
You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse orderand each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Example
两链表求和,重点是保存进位标识(carry),每遍历一次就新建一个节点并将新节点插入到结果链表中。