#mergetwolists
Explore tagged Tumblr posts
arifinfrds-blog · 2 years ago
Photo
Tumblr media
Leetcode - merge Two Lists using recursive #arifinfrds #leetcode #leetcodesolution #datastructuresandalgorithms #programmer #softwarengineer #swiftprogramming #softwaredeveloper #linkedlist #mergetwolists #recursive https://www.instagram.com/p/CnTqQ17y-jN/?igshid=NGJjMDIxMWI=
1 note · View note
kagaya25 · 5 years ago
Text
Leetcode Problem#21. Merge Two Sorted Lists
Leetcode Problem#21. Merge Two Sorted Lists
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.
Example:
Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4
Solution:
class Solution { public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode dummy{0}; auto curr = &dummy; while (l1 && l2) { if (l1->val val)…
View On WordPress
0 notes