Member-only story

How to Merge 2 Sorted Arrays Using Constant Space | coding interview | Arrays

Ganesh Prasad
4 min readSep 1, 2021

--

In-place merge 2 sorted arrays

This problem is from the medium category and has been asked by many companies such as LinkedIn, Quickr, Adobe, Microsoft, Goldman Sachs, Snapdeal and a few more.

Part of the 30 Days Preparation plan.

Table of Contents

Description

We are given 2 sorted arrays A and B, and we want to sort the arrays without any extra space.

Example:

Input:
A = [3 4 5 7 9]
B = [1 6 8]
Output:
A = [1 3 4 5 6]
B = [7 8 9]

Explanation: All the elements of A and B are sorted without any extra space, only using the Array A and B.

Do you want to stay updated on Coding interview tips and new Questions? Please click on subscribe button to get an email when the new tutorial is published.

How to sort 2 Sorted Arrays using Constant…

--

--

Ganesh Prasad
Ganesh Prasad

Written by Ganesh Prasad

Backend Developer at Appscrip | C++ veteran, 💜 Dart

No responses yet