Leetcode
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Example
Example
Example
下面節錄至wiki
Singly linked list
Singly linked lists contain nodes which have a data field as well as 'next' field, which points to the next node in line of nodes. Operations that can be performed on singly linked lists include insertion, deletion and traversal.
簡單的說就是每個node裡面會包含兩個field, 一個是當前node的值,另外是指向下一個node的指標,最後一個節點則指向一個空值(null or None)。
然後參考 leetCode 上面解答,如下圖
wiki
https://zh.wikipedia.org/wiki/链表
Linked List: Intro
https://medium.com/@havbgbg68/leetcode-2-add-to-numbers-python-63e4d5ba1534