Skip to content

Commit d1efe93

Browse files
Merge pull request #105 from IamSohamDey/patch-1
Create mergeTwoLists.c
2 parents e7590dc + f18db40 commit d1efe93

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

mergeTwoLists.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution
2+
{
3+
public ListNode mergeTwoLists(ListNode l1, ListNode l2)
4+
{
5+
if (l1 == null)
6+
{
7+
return l2;
8+
}
9+
else if (l2 == null)
10+
{
11+
return l1;
12+
}
13+
else if (l1.val < l2.val)
14+
{
15+
l1.next = mergeTwoLists(l1.next, l2);
16+
return l1;
17+
}
18+
else
19+
{
20+
l2.next = mergeTwoLists(l1, l2.next);
21+
return l2;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)