地址: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. 手把手教你把Vim改装成一个IDE编程环境(图文)

    http://blog.csdn.net/wooin/article/details/1858917

  2. 如何在PADS的封装中做非金属化孔

    在设置封装的pads stacks的页面里,diameter,drill,plated三个项目(盘外径60mil,孔30mil) diameter:60,drill:30,plated:checked ...

  3. CUBRID学习笔记 12防火墙设置 linux

    这玩意是linux上用的. 如果你的数据库不是装在linux下可以飘过了 iptables -I INPUT -p tcp --dport 8001 -j ACCEPT iptables -I INP ...

  4. FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)

    FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼) Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目 ...

  5. eclipse 实用快捷键

    Ctrl+E: 弹出输入窗口,可快速返回想返回的目标界面 Ctrl+Shift+O: 快速import包 Ctrl+O:显示类中方法和属性的大纲 Ctrl+1 快速修复 Ctrl+Alt+↓ 复制当前 ...

  6. 【CC评网】2013.第41周 不求排版,简单就好

    书单 碰上国庆,加上这周,消化掉几本书: <软件随想录>:Joel的随想录,也就是他Blog上的文章的摘选:整本书看下来轻松:写了篇读书笔记[传送门]: <中国在梁庄>:这本书 ...

  7. 模仿$.Callbacks实现

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. mongoDB中的ID的生成原则

  9. SQL触发器、事务

    触发器: 触发器为特殊类型的存储过程,可在执行语言事件时自动生效.SQL Server 包括三种常规类型的触发器:DML 触发器.DDL 触发器和登录触发器. 当服务器或数据库中发生数据定义语言 (D ...

  10. [转载] 每周推荐阅读 BFQ:实现IO的隔离共享与高吞吐访问

    磁盘IO和网络IO隔离与共享是混部应用中基本需求,从早些年的BVC到现在的Matrix,以及Galaxy,或者未来的BS/Mint混部都遇到类似的问题:由于无法有效实现IO级的隔离(包括吞吐隔离.延时 ...