Solve matrix components, median, and traversals | Meta
|Home/Coding & Algorithms/Meta
Solve matrix components, median, and traversals
Meta
Aug 11, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
0
0
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).
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.
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.