text: /**
   * Definition for singly-linked list.
   * struct ListNode {
   *     int val;
   *     ListNode *next;
   *     ListNode() : val(0), next(nullptr) {}
   *     ListNode(int x) : val(x), next(nullptr) {}
   *     ListNode(int x, ListNode *next) : val(x), next(next) {}
   * };
   */
  class Solution {
  public:
      ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) 
      {
           if(l1==NULL) 
               return l2;
          if(l2==NULL) 
              return l1;
          //Assigning L1 to be smallest one
          if(l1->val>l2->val)
          {
              ListNode* temp=l1;
              l1=l2;
              l2=temp;
          }
          ListNode* res=l1;
          while(l1!=NULL && l2!=NULL){
              ListNode* t=NULL;
              while(l1!=NULL && l1->val<=l2->val){
                  t=l1;
                  l1=l1->next;
              }
              t->next=l2;
              
              //swap if L1 is bigger
              ListNode* temp=l1;
              l1=l2;
              l2=temp;
          }
          return res;
          
      }
  };