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
<Solution>Output: 7 -> 0 -> 8
這題是要相加兩個 link list,解題想法和 415. Add Stings 一樣,可以參考那篇文章
差別點只在於 data structure 不同,修改成操作 link list 的方式就可以了
code 如下
c++
Java
沒有留言:
張貼留言