Minutes for a Rumor to Reach Every Reachable Group Member
Last updated: November 29, 2026
Quick Overview
A grid models seats in a group chat room: 0 is empty, 1 is an uninformed member, 2 is a member who knows the rumor. Each minute, informed members tell their four neighbors. Return the minutes until everyone is informed, or -1 if someone never hears it.
Meta
November 29, 20260
0
0 solved
A grid models seats in a group chat room: 0 is empty, 1 is an uninformed member, 2 is a member who knows the rumor. Each minute, informed members tell their four neighbors. Return the minutes until everyone is informed, or -1 if someone never hears it.
Multi-source BFS is a common Meta screen topic, and spread through a network is a natural framing for a social company. The interviewer checks that you start from all sources at once, count levels correctly, and detect unreachable cells.
What the Interviewer Expects
- Seeds the BFS queue with every initial source
- Processes level by level to count minutes
- Marks cells when enqueued to avoid duplicates
- Counts remaining uninformed cells to detect -1
- Returns 0 when nobody needs informing
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Some members need to hear the rumor twice before passing it on. How does that change things?
- Return the minute at which each member is informed.
- The graph is a friend network instead of a grid; what changes?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Grid up to 300 by 300. Spread is to up, down, left, right. Output minimum minutes, 0 if no 1s exist initially, -1 if some 1 is unreachable....
High-Level Design
Running a BFS from each source separately would be too slow and would count the wrong distance. Instead, push all 2s into one queue at time 0 and count the 1s. Process the queue one level at a time; e...