PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Solve array merge and tree flattening problems

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design and analyze algorithms on arrays and tree-based linked structures, focusing on merging sorted arrays (comparing in-place and extra-buffer approaches, stability, and complexity) and flattening a binary tree into a preorder-linked list with in-place pointer manipulation.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve array merge and tree flattening problems

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: HR Screen

1) Given two sorted arrays, merge them into a single sorted array. Provide both an in-place approach (when the first array has enough trailing capacity) and an approach using extra buffer. Analyze time and space complexity for each, and discuss stability. 2) Given a binary tree, flatten it in-place to a singly linked list following preorder traversal such that each node's right pointer points to the next node and all left pointers are null. Describe the algorithm, prove correctness, and analyze time and space complexity.

Quick Answer: This question evaluates a candidate's ability to design and analyze algorithms on arrays and tree-based linked structures, focusing on merging sorted arrays (comparing in-place and extra-buffer approaches, stability, and complexity) and flattening a binary tree into a preorder-linked list with in-place pointer manipulation.

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
Aug 9, 2025, 12:00 AM
Software Engineer
HR Screen
Coding & Algorithms
0
0
  1. Given two sorted arrays, merge them into a single sorted array. Provide both an in-place approach (when the first array has enough trailing capacity) and an approach using extra buffer. Analyze time and space complexity for each, and discuss stability.
  2. Given a binary tree, flatten it in-place to a singly linked list following preorder traversal such that each node's right pointer points to the next node and all left pointers are null. Describe the algorithm, prove correctness, and analyze time and space complexity.

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.