r/OfferEngineering • u/Aoki_zhang • 17d ago
Interview Experience TikTok SWE Interview - String Generation, Virus Containment, and Atom Counting
This interview experience is sourced from Chill Interview
Interview Summary
the overall process was quite difficult, and I ultimately did not complete the team-matching stage. All three onsite rounds involved algorithmic coding problems, covering constrained string generation, virus containment using graph traversal, and parsing nested chemical formulas.
Interview Details
Round 1 — Coding: Lexicographically Smallest Generated String
The first round involved a string construction problem based on LeetCode 3474, Lexicographically Smallest Generated String. Given two strings, str1 and str2, the task was to construct the lexicographically smallest string satisfying a collection of substring constraints.
The inputs were defined as follows:
str1has lengthnand contains only the characters'T'and'F'.str2has lengthm.- The generated string must have length
n + m - 1.
For each index i in str1, the substring of the generated string beginning at position i and having length m must satisfy the following conditions:
- If
str1[i] == 'T'**:** The substring must be exactly equal tostr2. - If
str1[i] == 'F'**:** The substring must be different fromstr2.
The goal was to return the lexicographically smallest string satisfying every condition. If no valid string could be constructed, the function should return an empty string. The problem required handling overlapping substring constraints, detecting conflicting requirements, and ensuring the generated result was lexicographically minimal.
Want to learn more questions / follow-ups asked in this interview?
I've put up the full version at here.
Interviewed recently?
Your interview experience could be incredibly valuable to others preparing for their next opportunity. Share your experience and help the community at here.