https://leetcode.com/problems/merge-two-sorted-lists/description/
class Solution {
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
ListNode tempHead = new ListNode(0);
ListNode temp = tempHead;
while(l1 != null && l2 != null){
if(l1.val <= l2.val){
tempHead.next = l1;
l1 = l1.next;
tempHead = tempHead.next;
} else{
tempHead.next = l2;
l2 = l2.next;
tempHead = tempHead.next;
}
}
if(l1 != null){
tempHead.next = l1;
}
if(l2 != null){
tempHead.next = l2;
}
return temp.next;
}
}