標籤:

演算法:2. Add Two Numbers

題目來自:

Add Two Numbersleetcode.com圖標

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 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.

Example

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8Explanation: 342 + 465 = 807.

思路:

時間複雜度O(n)

空間複雜度 O(1)


推薦閱讀:

今日頭條演算法原理(全)
機器學慣用於金融市場預測難在哪?
單機事務不同隔離級別的並發問題整理
演算法教練談談碼工面試

TAG:演算法 |