Add Two Numbers 2

来源:互联网 发布:iphone4 7.1.2越狱优化 编辑:程序博客网 时间:2024/05/16 05:06

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

两个链表,反向存储,

2->4->3   代表342

5->6->4  代表46

相加为    807   7 -> 0 -> 8

注意进位是反向进位,


超大数相加

见到的方法

1)多项式  a1*x^n +a2*x^(n-1) ....ak*x^(k) ....am*x^0


2)链表    两个链表可能不是一样道长度,多余的长度链表直接 拷过去

逆向存储,不用考虑位对齐,首位是个位。。。

特征




0 0
原创粉丝点击