TikTok logo

TikTok Hard Interview Questions

5 hard-level practice questions for TikTok technical interviews

TikTok software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. [CodeSignal] Synchronized Pipeline Delays


Category: Binary tree coding problem
A hierarchical data pipeline consists of n broadcast stages, numbered 1 to n, arranged in a perfect binary tree rooted at stage 0. Each stage...
Input: Binary tree
Output: Computed result
coding Hard Verified Question #2

2. Dual Extremes Queue


Category: Queue-based coding problem
Design a StreamBuffer class that buffers a stream of integer latency samples in FIFO order and supports O(1) access to both the minimum and maximum...
Input: Integer(s)
Output: Integer
coding Hard Verified Question #3

3. Spread Avoidance Escape


Category: Grid/matrix coding problem
You are navigating a facility grid to escape from spreading contamination. The grid contains: - 'S' - your starting position - 'C' - the...
Input: 2D grid
Output: Integer
coding Hard Verified Question #4

4. Tiered Order Pricing


Category: String coding problem
A warehouse fulfillment system batches orders to minimize shipping costs. Orders for the same SKU that are placed within 5 minutes (300,000 ms) of...
Input: String
Output: Integer
coding Hard graph #1

1. Graph — Finding Influencer Networks

Background: With the growth of user-generated content, TikTok needs to identify and analyze influencer groups to improve marketing strategies. Understanding how users are connected through likes and follows can help in targeted advertising and trend forecasting.
Problem statement: Given a directed graph represented by an adjacency list, where each node represents a user and a directed edge from user A to user B means that user A follows user B, write a function to find all strongly connected components (SCCs) in the graph. An SCC is a subgraph where every vertex can be reached from every other vertex. Implement the function find_scc(graph: List[List[int]]) -> List[List[int]] that returns a list of lists, where each inner list is a component.
Function/class signature:
  • def find_scc(graph: List[List[int]]) -> List[List[int]]:

Example 1:
  • Input: graph = [[1], [2], [0], [4], [5], [4]]

  • Output: [[0, 1, 2], [4, 5]]

  • Explanation: The nodes 0, 1, 2 form one SCC and nodes 4, 5 form another since 4 follows 5.

Example 2:
  • Input: graph = [[1], [], [3], [2]]

  • Output: [[0, 1], [2, 3]]

  • Explanation: Node 0 connects to 1, forming an SCC. Nodes 2 and 3 form another because each can reach the other.

Constraints:
  • 1 <= graph.length <= 1000

  • 0 <= graph[i].length <= graph.length

  • Each node identifier is within the range of the list index.

Start practicing TikTok questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free