def merge(left: list, right: list) -> list:
    """Merges 2 sorted lists (left and right) in 1 single list, which is
    returned at the end.

    Time complexity: O(m), where m = len(left) + len(right)."""
    mid = []
    i = 0  # Used to index the left list.
    j = 0  # Used to index the right list.

    while i < len(left) and j < len(right):
        if left[i] < right[j]:
            mid.append(left[i])
            i += 1
        else:
            mid.append(right[j])
            j += 1

    while i < len(left):
        mid.append(left[i])
        i += 1

    while j < len(right):
        mid.append(right[j])
        j += 1

    return mid