Close
Topic list
Merge Two Sorted Arrays
MEDIUM
15 mins
Sorting
Topics (Covered in this problem)
Problem solved
Skill meter
Sorting
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Merge Two Sorted Arrays

Contributed by
Ashwani
Medium
0/80
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### For example:

``````‘ARR1’ = [3 6 9 0 0]
‘ARR2’ = [4 10]
After merging the ‘ARR1’ and ‘ARR2’ in ‘ARR1’.
‘ARR1’ = [3 4 6 9 10]
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
3 2
1 2 3 0 0
4 5
4 2
1 4 6 10 0 0
2 5
``````

#### Sample Output 1:

``````1 2 3 4 5
1 2 4 5 6 10
``````

#### Explanation for Sample Output 1:

``````For sample test case 1:
In this test case, After merging ‘ARR2’ into ‘ARR1’.
‘ARR1’ = [1 2 3 4 5]

For sample test case 2:
In this test case, After merging ‘ARR2’ into ‘ARR1’.
‘ARR1’ = [1 2 4 5 6 10]
``````
##### Sample Input 2:
``````2
2 3
1 10 0 0 0
3 8 11
3 3
3 4 6 0 0 0
1 8 10
``````

#### Sample Output 2:

``````1 3 8 10 11
1 3 4 6 8 10
``````

#### Explanation for Sample Output 2:

``````For sample test case 1:
In this test case, After merging ‘ARR2’ into ‘ARR1’.
‘ARR1’ = [1 3 8 10 11]

For sample test case 2:
In this test case, After merging ‘ARR2’ into ‘ARR1’.
‘ARR1’ = [1 3 4 6 8 10]
``````
Auto
Console