PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Solve array merge, tree view, and maze tasks

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array manipulation and in-place algorithms, binary tree traversal and visibility reasoning, and grid graph traversal for path existence and shortest paths, reflecting competencies in data structures, algorithmic complexity, and space- and time-efficient implementations.

  • medium
  • Meta
  • Coding & Algorithms
  • Machine Learning Engineer

Solve array merge, tree view, and maze tasks

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Solve the following coding tasks. ## 1) Merge two sorted arrays in-place You are given two integer arrays `A` and `B`, each sorted in non-decreasing order. - `A` has length `m + n`, where the first `m` elements are valid, and the last `n` elements are extra space. - `B` has length `n`. **Task:** Modify `A` in-place so that it becomes a single sorted array containing all `m + n` elements. **Constraints (typical):** `0 ≤ m, n ≤ 2e5`, values fit in 32-bit signed int. ## 2) Right-side view of a binary tree (variant) Given the root of a binary tree, return the list of node values visible when looking at the tree from the right side (i.e., the last node encountered at each depth when scanning left-to-right). **Task:** Output the values from top to bottom. **Constraints (typical):** up to `2e5` nodes. ## 3) Maze problem (multi-part) You are given a 2D grid representing a maze: - `'.'` = empty cell, `'#'` = wall - `'S'` = start, `'E'` = end - You can move in 4 directions (up/down/left/right) to non-wall cells. **Tasks:** A. Determine whether a path exists from `S` to `E`. B. If a path exists, return the length of the shortest path (number of moves). C. Optionally, return one shortest path as a string over `{U,D,L,R}`. **Constraints (typical):** grid size up to `2000 x 2000` (so algorithms should be near-linear in number of cells).

Quick Answer: This question evaluates array manipulation and in-place algorithms, binary tree traversal and visibility reasoning, and grid graph traversal for path existence and shortest paths, reflecting competencies in data structures, algorithmic complexity, and space- and time-efficient implementations.

Related Interview Questions

  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Array, Matrix, and Recommendation Problems - Meta (medium)
  • Find a String Containing Another - Meta (medium)
  • Solve Subarray Sum and Local Minimum - Meta (hard)
  • Validate abbreviations and brackets - Meta (medium)
Meta logo
Meta
Dec 9, 2025, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
1
0
Loading...

Solve the following coding tasks.

1) Merge two sorted arrays in-place

You are given two integer arrays A and B, each sorted in non-decreasing order.

  • A has length m + n , where the first m elements are valid, and the last n elements are extra space.
  • B has length n .

Task: Modify A in-place so that it becomes a single sorted array containing all m + n elements.

Constraints (typical): 0 ≤ m, n ≤ 2e5, values fit in 32-bit signed int.

2) Right-side view of a binary tree (variant)

Given the root of a binary tree, return the list of node values visible when looking at the tree from the right side (i.e., the last node encountered at each depth when scanning left-to-right).

Task: Output the values from top to bottom.

Constraints (typical): up to 2e5 nodes.

3) Maze problem (multi-part)

You are given a 2D grid representing a maze:

  • '.' = empty cell, '#' = wall
  • 'S' = start, 'E' = end
  • You can move in 4 directions (up/down/left/right) to non-wall cells.

Tasks: A. Determine whether a path exists from S to E. B. If a path exists, return the length of the shortest path (number of moves). C. Optionally, return one shortest path as a string over {U,D,L,R}.

Constraints (typical): grid size up to 2000 x 2000 (so algorithms should be near-linear in number of cells).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Machine Learning Engineer•Meta Machine Learning Engineer•Meta Coding & Algorithms•Machine Learning 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.