Member-only story
How to Merge 2 Sorted Arrays Using Constant Space | coding interview | Arrays
4 min readSep 1, 2021
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
- Algorithm (with animation)
- Code and Explanation
- Time & Space Complexity
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.