left and right, and a number size. Pick exactly size digits from the two rows (any number from each row, possibly none) and lay them out in a single line. Digits taken from the same row must keep their order from that row; digits from different rows may be interleaved freely.
Return the line that is the largest as a size-digit number, as an array of digits.left=[2, 7, 1], right=[5, 8, 3, 6], size=4 → [8, 7, 6, 1]
Take 7 and 1 from left and 8 and 6 from right, then interleave them keeping each row's order: [8, 7, 6, 1]. No larger four-digit number can be built.
left=[4, 0], right=[4, 9], size=4 → [4, 9, 4, 0]
All digits are needed. Take the 4 from right first to reach its 9, then 9, 4, 0: the answer is [4, 9, 4, 0].
left=[1, 5], right=[3], size=1 → [5]
left=[2, 7, 1], right=[5, 8, 3, 6], size=4
[8, 7, 6, 1]
Run checks the first 3 tests in your browser. Submit checks all 119 tests on the server, hidden ones included.