leetcode---merge-two-sorted-lists---链表
来源:互联网 发布:centos 7.3 安装vftp 编辑:程序博客网 时间:2024/06/01 10:19
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { if(!l1) return l2; if(!l2) return l1; ListNode *head = new ListNode(0); ListNode *p = l1, *q = l2; ListNode *pp = head; while(p && q) { if(p->val < q->val) { pp->next = p; p = p->next; pp = pp->next; } else { pp->next = q; q = q->next; pp = pp->next; } } if(p) pp->next = p; if(q) pp->next = q; return head->next; }};
阅读全文
0 0
- leetcode[21 链表]Merge Two Sorted Lists
- LeetCode[链表] - #21 Merge Two Sorted Lists
- [LeetCode][链表]Merge Two Sorted Lists
- LeetCode 21. Merge Two Sorted Lists(链表)
- leetcode---merge-two-sorted-lists---链表
- LeetCode: Merge Two Sorted Lists
- [Leetcode] Merge Two Sorted Lists
- Leetcode: Merge Two Sorted Lists
- [LeetCode] Merge Two Sorted Lists
- [Leetcode] Merge two sorted lists
- leetcode Merge Two Sorted Lists
- [LeetCode]Merge Two Sorted Lists
- [leetcode]Merge Two Sorted Lists
- LeetCode-Merge Two Sorted Lists
- [leetcode] Merge Two Sorted Lists
- [LeetCode] Merge Two Sorted Lists
- LeetCode - Merge Two Sorted Lists
- LeetCode:Merge Two Sorted Lists
- dubbo和spring boot整合简约版(xml和annotation)
- Faster RCNN win版本
- 这是在遇到ftp用了多种方法均无法使用后找到的一种方法
- SpringMVC获取页面参数的五种方法
- 两个数的加减乘除
- leetcode---merge-two-sorted-lists---链表
- 关于做crm系统中查询所有联系人功能报出的异常
- Zookeeper
- Java_Object_wait()、notify()、notifyAll()
- Sat Oct 21 17:54:29 CST 2017 There was an unexpected error (type=Not Found, status=404).
- 心得
- 写给自己的JAVA工程师之路-MySQL函数
- 无限大地图:lightmap拆分
- [参考]matlab数字滤波器设计函数一览