PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Solve matrix components, median, and traversals

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving across grid and graph algorithms, selection algorithms, and traversal techniques—specifically connected-component detection in binary matrices, median-finding across two sorted arrays, and BFS/DFS traversal variants—measuring competence in data structures, complexity analysis, and handling edge cases. Commonly asked in Coding & Algorithms interviews for Machine Learning Engineer roles, it assesses efficiency and correctness concerns such as time and space complexity and traversal orders, testing both conceptual understanding of algorithmic principles and practical implementation distinctions like iterative versus recursive variants.

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

Solve matrix components, median, and traversals

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

1) Binary matrix component: Given an m x n grid of 0s (background) and 1s (objects), return the size of the largest connected component where connectivity is 4-directional (up, down, left, right). Describe the algorithm, time and space complexity, and edge cases (e.g., empty grid, all zeros, all ones). 2) Median of two sorted arrays: Given two sorted arrays A (length m) and B (length n), compute the median of the combined multiset without fully merging them. Explain the fastest approach you would implement, its time and space complexity, and how you would handle even total length. 3) Graph traversals: Given an undirected graph that may be disconnected, implement BFS and DFS that return the visitation order for all vertices. Provide both recursive and iterative variants where applicable, and analyze time and space complexity.

Quick Answer: This question evaluates algorithmic problem-solving across grid and graph algorithms, selection algorithms, and traversal techniques—specifically connected-component detection in binary matrices, median-finding across two sorted arrays, and BFS/DFS traversal variants—measuring competence in data structures, complexity analysis, and handling edge cases. Commonly asked in Coding & Algorithms interviews for Machine Learning Engineer roles, it assesses efficiency and correctness concerns such as time and space complexity and traversal orders, testing both conceptual understanding of algorithmic principles and practical implementation distinctions like iterative versus recursive variants.

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
Aug 11, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
2
0
  1. Binary matrix component: Given an m x n grid of 0s (background) and 1s (objects), return the size of the largest connected component where connectivity is 4-directional (up, down, left, right). Describe the algorithm, time and space complexity, and edge cases (e.g., empty grid, all zeros, all ones).
  2. Median of two sorted arrays: Given two sorted arrays A (length m) and B (length n), compute the median of the combined multiset without fully merging them. Explain the fastest approach you would implement, its time and space complexity, and how you would handle even total length.
  3. Graph traversals: Given an undirected graph that may be disconnected, implement BFS and DFS that return the visitation order for all vertices. Provide both recursive and iterative variants where applicable, 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 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.