https://leetcode.com/problems/merge-two-sorted-lists/description/?envType=study-plan-v2&envId=top-interview-150

def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
	if not list1: return list2
	if not list2: return list1
	
	pointer = dummy = ListNode()
	while list1 and list2:
	    if list1.val > list2.val:
	        pointer.next = list2
	        list2 = list2.next
	    else:
	        pointer.next = list1
	        list1 = list1.next
	    pointer = pointer.next
	
	if list1:
	    pointer.next = list1
	
	if list2:
	    pointer.next = list2
	
	return dummy.next

$Time = O(N+M)$

$Space = O(1)$