public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
    	if(l1 == null) return l2;
        if(l2 == null) return l1; 
        ListNode res = null;
        ListNode head = null;


    	while(l1 != null && l2 !=null)
    	{
    		if(l1.val<l2.val)
    		{
    			if(res == null)
    			{
    				res = l1;
    				head = l1;
    			}
    			else
    				res.next =l1;
    			l1=l1.next;
    		}else
    		{
    			if(res == null)
    			{
    				res = l2;
    				head = l2;
    			}
    			else
    				res.next =l2;
    			l2=l2.next;
    		}
    	}
    	
    	if(l1 == null) res.next= l2;
    	if(l2 == null) res.next= l1;
    	
    	return head;
    }