445. Add Two Numbers II

96
我是你的果果呀
2016.12.21 11:28* 字数 172

You are given two linked lists representing two non-negative numbers. The most significant digit comes first and 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.

Follow up: What if you cannot modify the input lists? In other words, reversing the lists is not allowed.
Example: Input:(7 -> 2 -> 4 -> 3) + (5 -> 6 -> 4)    Output:7 -> 8 -> 0 -> 7

要求不能改动input, 也就是说要建立一个新的list, 第一种方法借用两个栈, 构建一个新的list, 这样空间复杂度高。

第二种方法就是借鉴+1 的记录最后一个不是9的位置, 

leetcode _medium