Problem Submissions Solution

Merge Sorted Arrays

Difficulty: Easy

Acceptance: %

Points: 20.00

You are given two sorted arrays, a[] and b[], both arranged in non-decreasing order. The task is to merge these arrays into a single sorted array without using extra space. Modify a so that it contains the first n elements and modify b so that it contains the last m elements.

Topics

Companies

Articles

Examples:

Expected Time Complexity O(n log m)

Expected Space Complexity O(1)

Constraints:
  • 1 <= a.size(), b.size() <= 10^5
  • 0 <= a[i], b[i] <= 10^7
Companies:
Microsoft Adobe Linkedin Goldman Sachs Zoho
Topics:
Array Sorting Algorithms
Locked Content
Access Restricted: Please Login to access the code editor and test cases.