Solve grid path and top‑k frequency
MetaSoftware Engineer · Technical ScreenLast updated
This question evaluates algorithmic problem-solving in grid reachability and frequency analysis, testing concepts such as grid/graph traversal and obstacle handling for path existence alongside frequency counting and selection for top-k elements.
Part A — Grid Reachability with Obstacles: Given an m×n matrix of 0s and 1s where 0 indicates a passable cell and 1 indicates a blocked cell, starting at (0, 0) determine whether there exists a path to the bottom-right cell (m−1,n− 1). You may move up, down, left, or right within bounds and cannot enter blocked cells. Return true if such a path exists, otherwise false.
Part B — Top‑K Frequent Numbers: Given an array of integers and an integer k, return the k numbers that appear most frequently in the array. If multiple numbers have the same frequency, any order among them is acceptable.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.