PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

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.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve grid path and top‑k frequency

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

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.

Quick Answer: 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.

Grid Reachability With Obstacles

Return whether a 4-neighbor path exists from top-left to bottom-right through zero cells.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([[0,0],[1,0]],)

Expected Output: True

Explanation: Path exists.

Input: ([[0,1],[1,0]],)

Expected Output: False

Explanation: No path through obstacles.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.

Top K Frequent Numbers

Return the k most frequent numbers, breaking ties by smaller numeric value.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,1,1,2,2,3], 2)

Expected Output: [1, 2]

Explanation: Return top two by frequency.

Input: ([4,4,5,5,6], 2)

Expected Output: [4, 5]

Explanation: Ties are broken by numeric value for deterministic output.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)