← back to unit
Challenge
# sorting advanced
Merge the Two Lunch Lines
Two lunch lines, each ALREADY sorted by height, must merge into one sorted line. 🥪
You get sorted list a and sorted list b. Merge them into one sorted list WITHOUT re-sorting: repeatedly take the smaller front. Print comma-separated.
Example:
Input: a = [1, 4, 9], b = [2, 3, 10]
Output: 1,2,3,4,9,10
Comparing fronts each round — 1 vs 2 (take 1), 4 vs 2 (take 2), 4 vs 3 (take 3), 4 vs 10 (take 4), 9 vs 10 (take 9), then 10 remains — builds the merged line without re-sorting.
💡 need a hint?
sort-merge-lunch-lines.py🔒 given lines are locked — write your code in between
loading...