leetcode new problems

This commit is contained in:
2026-02-11 14:48:41 +05:30
parent 192ce44a81
commit 0f52d46c67
29 changed files with 658 additions and 5 deletions
+17
View File
@@ -0,0 +1,17 @@
class Solution{
public :
ListNode* mergeTwoLists(ListNode* l1, ListNode* l2){
if(!l1 || !l2)
return l1? l1: l2;
if(l1->val > l2->val)
swap(l1,l2);
l1->next = mergeTwoLists(l1->next, l2);
return l1;
}
}
//At every step, pick the smaller head node, attach it to the result,and recursively merge the remaining lists
//TC : O(m+n)
//SC: O(m+n), recursion stack space