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
Coding & Algorithms
Software Engineer
ByteDance
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
multi-source BFS
grid graphs
level order
reachability
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported