layout: post title: "[电脑网络]Add two numbers" date: '2014-08-21T11:43:00.003-08:00' author: Qingyang tags:
The leetcode question "adding two numbers" (https://oj.leetcode.com/problems/add-two-numbers/) is a hard on for me. But I got to understand the concept of linked list and finally was able to manipulate it after finishing this question.<br /><br />The Question.:<br /><div><br /></div><div><blockquote class="tr_bq" style="background-color: white; box-sizing: border-box; color: #333333; font-family: monospace; font-size: 14px; line-height: 30px; margin-bottom: 10px;">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.<br /><b style="box-sizing: border-box;">Input:</b> (2 -> 4 -> 3) + (5 -> 6 -> 4)<br /><b style="box-sizing: border-box;">Output:</b> 7 -> 0 -> 8</blockquote></div><div>My solution can be found <a href="http://www.codeskulptor.org/#user37_Y7MW3dYM0F_2.py" target="_blank">here</a>.<br /><br />The hard part is figuring out how to create new nodes and move to next node of the linked list. Once I got this the problem was not too hard to solve.<br /><br /><br /><br /><br /><br /><br /></div>