PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Merge two sorted arrays in-place

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competency in in-place array manipulation and algorithmic complexity analysis, emphasizing maintenance of sorted order under constant-space constraints.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Merge two sorted arrays in-place

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given two sorted integer arrays `nums1` and `nums2`. - `nums1` has length `m + n`. The first `m` elements contain the sorted data in non-decreasing order. The last `n` elements are placeholders (for example, zeros) and should be ignored. - `nums2` has length `n` and contains `n` sorted elements in non-decreasing order. Merge `nums2` into `nums1` so that `nums1` becomes a single sorted array of length `m + n`, still in non-decreasing order. You must perform the merge **in-place** in `nums1`, using only O(1) additional space. Describe your algorithm in detail and analyze its time and space complexity. You do not need to provide actual code.

Quick Answer: This question evaluates a candidate's competency in in-place array manipulation and algorithmic complexity analysis, emphasizing maintenance of sorted order under constant-space constraints.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Dec 8, 2025, 7:54 PM
Software Engineer
Onsite
Coding & Algorithms
3
0

You are given two sorted integer arrays nums1 and nums2.

  • nums1 has length m + n . The first m elements contain the sorted data in non-decreasing order. The last n elements are placeholders (for example, zeros) and should be ignored.
  • nums2 has length n and contains n sorted elements in non-decreasing order.

Merge nums2 into nums1 so that nums1 becomes a single sorted array of length m + n, still in non-decreasing order.

You must perform the merge in-place in nums1, using only O(1) additional space.

Describe your algorithm in detail and analyze its time and space complexity. You do not need to provide actual code.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.