Leetcode Week9
来源:互联网 发布:前端wap 淘宝页面模板 编辑:程序博客网 时间:2024/06/06 07:42
/*
9.列表式数字的相加 add two number
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.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
9.列表式数字的相加 add two number
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.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
*/
/* /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ /*class Solution {public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { int carry = 0; ListNode* tail = new ListNode(0); ListNode* ptr = tail; while(l1 != NULL || l2 != NULL){ int val1=0; if(l1 != NULL){ val1 = l1->val; l1 = l1->next; } int val2=0; if(l2 != NULL){ val2 = l2->val; l2 = l2->next; } int temp = val1 + val2 +carry; ptr->next = new ListNode(temp % 10); carry = temp / 10; ptr = ptr->next; } if(carry == 1){ ptr->next = new ListNode(1); } return tail->next; }};*/
0 0
- Leetcode Week9
- leetcode week9
- leetcode-month2-week9
- LeetCode题解 week9
- WEEK9
- Leetcode: 34. Search for range(Week9, Medium)
- LeetCode Week9: Binary Tree Preorder/InOrder/PostOrder Traversal
- LeetCode#718 Maximum Length of Repeated Subarray (week9)
- [LeetCode-Algorithms-65] "Valid Number" (2017.11.1-WEEK9)
- [LeetCode-Algorithms-20] "Valid Parentheses" (2017.11.1-WEEK9)
- week9-leetcode #19-Remove-Nth-Node-From-End-of-List
- Week9练习
- Week9 练习
- Algorithm-week9
- 算法设计Week9 LeetCode Algorithms Problem #121. Best Time to Buy and Sell Stock
- Week9 H-IN
- WEEK9 JAVA作业
- [week9]每周总结与工作计划
- 【数据库知识补充】模式与对象的关系
- 数据结构——线性表基本操作
- Source Insight 3.5显示行号
- 二维多项式求值
- DPC的使用方法
- Leetcode Week9
- C# 枚举(Enum)
- 写给自己
- AngularJS教程 AngularJS从0到1——HelloWorld
- C# 类(Class)
- 深度优先搜索算法—DFS
- Android商品展示小案例
- JAVA代码优化常用方法
- java性能优化注意的几个细节规则