Time for a Trending Sound to Reach Every Reachable Creator

Last updated: November 29, 2026

Quick Overview

A grid represents creator communities: 0 is empty, 1 is a creator who has not used a sound, and 2 is a creator already using it. Each hour, every creator using the sound influences adjacent (up, down, left, right) creators. Return the hours until no new creator can adopt it, and whether any creator is never reached.

TikTok
Coding & Algorithms
Software Engineer
TikTok
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


A grid represents creator communities: 0 is empty, 1 is a creator who has not used a sound, and 2 is a creator already using it. Each hour, every creator using the sound influences adjacent (up, down, left, right) creators. Return the hours until no new creator can adopt it, and whether any creator is never reached.

Trend propagation is central to TikTok's culture around sounds and challenges, and this multi-source BFS question appears in technical screens. The interviewer checks whether you start BFS from all sources at once and count levels correctly.

What the Interviewer Expects
  • Seeds the BFS queue with every initial adopter simultaneously
  • Processes level by level to count hours
  • Marks cells when enqueued to avoid duplicates
  • Reports unreachable creators instead of silently ignoring them
  • Handles grids with no creators or no initial adopters
Key Topics to Cover
multi-source BFS
grids
level order
simulation
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
  • What if influence takes different times depending on the edge (weighted spread)?
  • How would you model creators who adopt only after two neighbors adopt?
  • How would you run this on a real follow graph with billions of edges?
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: 2D list of 0, 1, 2.
  • Output: (hours, all_reached), where hours is the time of the last new adoption (0 if none happen).
  • Spread is 4-directional, one step per hour....
High-Level Design

Multi-source BFS. Put all 2s in the queue at time 0 and count remaining 1s. Process the queue one level at a time; each level is one hour. Every 1 neighbor becomes 2, decreases the remaining count, an...


Submit Your Answer
Markdown supported