#mergetwolists
Explore tagged Tumblr posts
Photo
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=
#arifinfrds#leetcode#leetcodesolution#datastructuresandalgorithms#programmer#softwarengineer#swiftprogramming#softwaredeveloper#linkedlist#mergetwolists#recursive
1 note
·
View note
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