package com.fishercoder.solutions;

import com.fishercoder.common.classes.ListNode;

/**
 * 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.*/

public class _21 {

    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if (l1 == null) {
            return l2;
        }
        if (l2 == null) {
            return l1;
        }
        if (l1.val < l2.val) {
            l1.next = mergeTwoLists(l1.next, l2);
            return l1;
        } else {
            l2.next = mergeTwoLists(l1, l2.next);
            return l2;
        }
    }

}

@@ -285,17 +285,56 @@
 s _21 %7B%0A
-%0A
+    public static class Solution1 %7B%0A    
     publ
@@ -391,24 +391,28 @@
 ) %7B%0A        
+    
 if (l1 == nu
@@ -421,32 +421,36 @@
 ) %7B%0A            
+    
 return l2;%0A     
@@ -436,32 +436,36 @@
      return l2;%0A
+    
         %7D%0A      
@@ -462,24 +462,28 @@
   %7D%0A        
+    
 if (l2 == nu
@@ -492,32 +492,36 @@
 ) %7B%0A            
+   
+ 
 return l1;%0A     
@@ -515,32 +515,36 @@
 urn l1;%0A        
+    
 %7D%0A        if (l1
@@ -533,24 +533,28 @@
   %7D%0A        
+ 
+   
 if (l1.val %3C
@@ -560,24 +560,28 @@
 %3C l2.val) %7B%0A
+    
             
@@ -622,32 +622,36 @@
 2);%0A            
+    
 return l1;%0A     
@@ -653,16 +653,20 @@
         
+ 
+   
 %7D else %7B
@@ -666,16 +666,20 @@
  else %7B%0A
+    
         
@@ -724,32 +724,36 @@
 t);%0A            
+    
 return l2;%0A     
@@ -739,32 +739,46 @@
      return l2;%0A
+            %7D%0A
         %7D%0A    %7D%0A

refactor 21