โ Back to Arrays
Question 398
Merge Two Sorted Arrays
Merge Two Sorted Arrays
Two already-sorted arraysa = {1, 3, 5, 7}andb = {2, 4, 6, 8}are given. Merge them into one sorted array and print it on a single line separated by single spaces: 1 2 3 4 5 6 7 8 Use the two-pointer merge technique: repeatedly take the smaller front element fromaorb. Do not just sort a concatenation.
Expected Output:
1 2 3 4 5 6 7 8
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.