地址:https://leetcode.com/problems/add-two-numbers/

代码:

class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
               ListNode *head;
        ListNode *current = );
        head = current;
        ;
        ) {
            if (l1 != NULL && l2 != NULL) {
                current->val = l1->val + l2->val + temp;
                l1 = l1->next;
                l2 = l2->next;
            } else if (l1 == NULL && l2 == NULL)
                current->val =  + temp;
            else if (l1 == NULL) {
                current->val = l2->val + temp;
                l2 = l2->next;
            } else if (l2 == NULL) {
                current->val = l1->val + temp;
                l1 = l1->next;
            }
            temp = ;
            ) {
                current->val %= ;
                temp = ;
            }
            ) {
                current->next = );
                current = current->next;
            }
        }
        return head;
    }
};

Leetcode--Add two number的更多相关文章

  1. [LeetCode] 247. Strobogrammatic Number II 对称数II

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

  2. [LeetCode] 248. Strobogrammatic Number III 对称数III

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

  3. Leetcode 202 Happy Number 弗洛伊德判环解循环

    今天先谈下弗洛伊德判环,弗洛伊德判环原来是在一个圈内有两人跑步,同时起跑,一人的速度是另一人的两倍,则那个人能在下一圈追上另一个人,弗洛伊德判环能解数字会循环出现的题,比如说判断一个链表是不是循环链表 ...

  4. Leetcode 137 Single Number II 仅出现一次的数字

    原题地址https://leetcode.com/problems/single-number-ii/ 题目描述Given an array of integers, every element ap ...

  5. leetcode 136 Single Number, 260 Single Number III

    leetcode 136. Single Number Given an array of integers, every element appears twice except for one. ...

  6. LeetCode 260. Single Number III(只出现一次的数字 III)

    LeetCode 260. Single Number III(只出现一次的数字 III)

  7. LeetCode 137. Single Number II(只出现一次的数字 II)

    LeetCode 137. Single Number II(只出现一次的数字 II)

  8. LeetCode 136. Single Number(只出现一次的数字)

    LeetCode 136. Single Number(只出现一次的数字)

  9. LeetCode 137 Single Number II(仅仅出现一次的数字 II)(*)

    翻译 给定一个整型数组,除了某个元素外其余的均出现了三次. 找出这个元素. 备注: 你的算法应该是线性时间复杂度. 你能够不用额外的空间来实现它吗? 原文 Given an array of inte ...

  10. LeetCode——Add Strings

    LeetCode--Add Strings Question Given two non-negative integers num1 and num2 represented as string, ...

随机推荐

  1. 我的android学习经历30

    数据存储的持久化技术 数据存储主要有五种方式: (1)文件存储或者SD卡 (2)SharedPreferences (3)SQLite (4)ContentProvider (5)网络存储 下面简单介 ...

  2. C#注册表操作,根据键取值

    string into = ""; RegistryKey key = Registry.LocalMachine; RegistryKey myreg = key.OpenSub ...

  3. Python存取XML方法简介

    <?xml version="1.0" encoding="utf-8"?> <Schools> <School Name=&qu ...

  4. ASP.NET API盘点

    1.控制只返回JSON一种数据 public class JsonContentNegotiator : IContentNegotiator { private readonly JsonMedia ...

  5. lncRNA研究

    ------------------------------- Long noncoding RNAs are rarely translated in two human cell lines. ( ...

  6. linux下inotify的使用

    有时候我们需要检测某个目录下文件或者子目录的改动状况,如添加.删除.以及更新等,Linux系统上提供了inotify来完成这个功能.inotify是在版本2.6.13的内核中首次出现,现在的发行本应该 ...

  7. C#中Application.DoEvents()的作用

    Visual Studio里的摘要:处理当前在消息队列中的所有 Windows 消息. 交出CPU控制权,让系统可以处理队列中的所有Windows消息,比如在大运算量循环内,加Application. ...

  8. VirtualBox全屏切换

    用VirtualBox的时候,如果设置为全屏,想再切换回来,没有什么菜单,只有通过键盘的快捷键来操作,才可以恢复. 我常常忘掉,所以老是得去找,以后需要记住这几个按键的快捷键. 1.全屏与非全屏切换: ...

  9. ubuntu 安装JDK

    下载JDK6安装包,我的为32位系统所以选择jdk-6u35-linux-i586.bin 下载地址:http://www.oracle.com/technetwork/java/javase/dow ...

  10. Scrum Meeting---One(2015-10-20)

    一.scrum meeting 在上周六我们团队进行了一次会议,讨论了我们团队的项目以及项目分工.首先是确立我们的项目,在团队的激烈讨论下我们决定做一个校园相关的APP.然后对于这个项目我们大致进行了 ...