Merge Two Sorted Arrays
hardQuestion 398Two already-sorted arrays a = {1, 3, 5, 7} and b = {2, 4, 6, 8} are given. Merge them into one sorted array and print it on a single line separated by single spaces (see Expected Output).
Use the two-pointer merge technique: repeatedly take the smaller front element from a or b. Do not just sort a concatenation.
Expected output
1 2 3 4 5 6 7 8= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.