CJCoding With Joseph
15free / daySign inCreate account

Two Finger Merge

Write merge(left: list[int], right: list[int]) -> list[int], the two-finger merge from merge sort: both lists are already sorted. Keep an index i on left and j on right; while neither has run out, append the smaller of the two values the fingers point at (the left one when they are equal) to merged and move that finger on. When one list is exhausted, the rest of the other follows unchanged, which the slices left[i:] and right[j:] give you. The result is sorted and the merge is O(n). Do NOT write a main block or any top-level test code; the tests construct the calls. Input: two lines, each a space-separated sorted list of integers (either may be empty); the tests print the list your function returns.

Expected Output:

[1, 2, 3, 4, 9, 10, 11]

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Data Structures & AlgorithmsBig-O
📥 Auto-Input:
1 4 9\n2 3 10 11\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.