一、题目叙述:
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.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
二、解题思路:
解一道Medium难度哒题,酷不酷呀(酷头!丢银),好啦说说解题思路喽,这个题是通过了,然而我并没有仔细推敲算法神马的,一切都以accepted为追求。。。就是用链表存储数字,将两个数字相加,然而由于数字存储顺序是反的,所以我们考虑进位时向后进位就OK了。总结下:
1、进位向后进位。
2、考虑一个数比另一个数长的情况
三、源源源码(我不结巴,这只是卖萌):