Tag: Algorithms 101: two linked lists
-
Algorithms 101: two linked lists
•
1. LeetCode 21: Merge Two Sorted Lists Solution and Time Complexity Analysis: # Python code class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def mergeTwoLists(l1: ListNode, l2: ListNode) -> ListNode: dummy = ListNode() current = dummy while l1 and l2: if l1.val < l2.val: # If…