Minutes Until a Breaking Story Reaches Every Toutiao Reader Cluster
Last updated: November 29, 2026
Quick Overview
On a grid where 2 marks clusters already showing a breaking story on Toutiao, 1 marks clusters that have not, and 0 marks empty cells, the story spreads to 4-adjacent clusters each minute; return the minutes until all clusters have it, or -1 if some never will.
ByteDance
November 29, 20260
0
0 solved
On a grid where 2 marks clusters already showing a breaking story on Toutiao, 1 marks clusters that have not, and 0 marks empty cells, the story spreads to 4-adjacent clusters each minute; return the minutes until all clusters have it, or -1 if some never will.
Toutiao's news distribution team thinks about how quickly a hot story saturates neighboring audience segments, and this multi-source BFS in ByteDance's screening style is a compact proxy. The interviewer is checking that you seed the queue with all sources at once and detect unreachable cells.
What the Interviewer Expects
- Start BFS from every source simultaneously
- Track the time level per cell or process level by level
- Count unreached cells to detect -1 without a second scan
- Avoid mutating the caller's grid, or say you will
- State O(rows * cols) time and space
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
- Return the minute each cluster first receives the story.
- Spread takes different times on different edges: what algorithm now?
- Only k clusters can be seeded: how would you pick them?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: a rectangular grid with values 0, 1, 2. Output: the minimum minutes until no 1 remains, 0 if there are no 1s at the start, or -1 if some 1 is unreachable from every 2....
High-Level Design
Multi-source BFS. Push every 2 with time 0, then pop cells and infect fresh neighbors with time + 1. Because BFS processes cells in nondecreasing time, the largest time popped is when the last cluster...