Challenge: Merge Two Sorted Arrays

Given two sorted arrays, merge them into one array which should also be sorted. Implement the solution in C++ and see if your code runs successfully!

Problem Statement #

Implement a function mergeArrays(int arr1[], int arr2[], int arr1Size,int arr2Size) which merges two sorted arrays into another sorted array. Definition of the function is given.

Input: #

Two sorted arrays and their sizes.

Output: #

A merged sorted array consisting of all elements of both input arrays.

Sample Input #

arr1 = [1,3,4,5]  
arr2 = [2,6,7,8]

Sample Output #

arr = [1,2,3,4,5,6,7,8]

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.