← TikTok Interview Insights

TikTok·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

TikTok software engineer coding round with two LeetCode-style problems. Both were on the harder side and the follow-up on the first one added a wrinkle I didn't fully see coming.

Questions Asked (2)

Q1

Given a message string and a per-character width limit, split the message into numbered parts where each part includes a suffix like '<1/8>', '<2/8>', etc. Follow-up: the suffix itself must be counted toward the width limit.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The base version isn't too bad once you figure out the suffix length math.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints, especially the circular dependency between the number of parts and the suffix width. Then propose an iterative approach: estimate the number of parts, compute the suffix width, and adjust until convergence. Finally, discuss how to split the message while ensuring each part plus its suffix fits within the limit.

Pro tip: Mention that the number of parts can be found by iterating until the suffix width stabilizes, and handle edge cases like when the limit is too small to fit even a single character with the suffix.

1. Clarify requirements and constraints

Ask about edge cases: what if the limit is smaller than the suffix length? Should we truncate or error? Also confirm if parts must be contiguous and non-empty.

2. Determine the number of parts

Since the suffix width depends on the total number of parts, use an iterative method: start with an estimate, compute suffix width, recalculate parts, and repeat until stable.

3. Compute available width per part

For each part, subtract the suffix length from the limit to get the maximum message characters that can be included.

4. Split the message into parts

Iterate through the message, taking chunks of the available width, and append the appropriate suffix to each chunk.

5. Handle edge cases and validate

Check if the limit is too small (e.g., less than suffix length plus 1), and ensure the last part may be shorter. Validate that all parts fit and the message is fully covered.

Key Points to Mention

  • Circular dependency between number of parts and suffix width
  • Iterative convergence to find the correct number of parts
  • Time and space complexity analysis (O(n) time, O(1) extra space if output not counted)
  • Edge cases: limit too small, empty message, single part
  • Trade-offs: precomputing suffix widths vs. dynamic adjustment
  • Handling large messages and potential integer overflow in part count

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Given an m x n candy board, repeatedly remove all horizontal or vertical runs of 3 or more identical candies, apply gravity to drop remaining candies down, and return the board once it stabilizes.

Algorithms & Data Structures
Author's notes

Simulation problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the process as a loop: repeatedly scan the board for horizontal and vertical runs of 3+ identical candies, mark them for removal, clear them, and apply gravity to each column. Continue until a full pass produces no removals, then return the stabilized board. Focus on correctness and clarity first, then discuss optimizations like using a queue of affected positions.

Pro tip: Clarify edge cases upfront (e.g., empty board, no matches, cascading matches) and mention that you can optimize by only rechecking rows/columns affected by gravity, which shows you think about efficiency beyond the naive approach.

1. Clarify requirements and edge cases

Confirm board dimensions, candy types, and that runs of exactly 3 or more are removed. Ask about empty boards, boards with no matches, and whether gravity applies simultaneously after all removals.

2. Design the removal detection

Explain how to scan each row for horizontal runs and each column for vertical runs, marking cells that are part of any run of length >= 3. Use a boolean matrix or set to record positions to remove.

3. Implement gravity

For each column, shift remaining candies downward to fill empty spaces, preserving their relative order. This can be done by collecting non-empty cells from bottom to top and rewriting the column.

4. Iterate until stable

Repeat detection, removal, and gravity in a loop. Break when a full pass finds no removable runs. Return the board.

5. Analyze complexity and optimizations

Discuss time complexity (e.g., O(m*n) per pass, up to O(m*n*max(m,n)) worst-case) and space complexity. Mention optimizations like tracking only affected rows/columns or using a queue of candidate positions.

Key Points to Mention

  • Use a visited/marked matrix to avoid double-counting cells in overlapping runs.
  • Apply gravity column by column, shifting candies down to fill empty spaces.
  • Loop until no changes occur to handle cascading removals.
  • Consider edge cases: empty board, no matches, full board of same candy.
  • Time complexity: O(m*n) per iteration, worst-case O(m*n*max(m,n)) iterations.
  • Optimization: only recheck rows/columns that changed after gravity.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.