Basic merge
Input
a = [1, 3, 5], b = [2, 4, 6]
Output
[1, 2, 3, 4, 5, 6]
Alternate elements from the two arrays in sorted order.
Full lesson preview
Merge two sorted lists into a single sorted list using the two-pointer technique.
Problem statement
Task
Examples
Input
a = [1, 3, 5], b = [2, 4, 6]
Output
[1, 2, 3, 4, 5, 6]
Alternate elements from the two arrays in sorted order.
Input format
Output format
Constraints
Samples
Input
merge_sorted_arrays([1,2], [3,4])
Output
[1, 2, 3, 4]
Simple concatenation in order using merge.