CCI题目2-4:Add Two Numbers in Link List

By | 2012 年 11 月 16 日

同Leetcode题目:Leetcode题目:两个链表数相加



题目
You have two numbers represented by a linked list, where each node contains a sin- gle digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list.
EXAMPLE
Input: (3 -> 1 -> 5) + (5 -> 9 -> 2)
Output: 8 -> 0 -> 8

发表评论

电子邮件地址不会被公开。 必填项已用*标注