Validate an Upload Job Against Its Allowed State Transitions
Last updated: November 29, 2026
Quick Overview
A video upload job moves through states CREATED, UPLOADING, UPLOADED, TRANSCODING, REVIEW and then PUBLISHED or REJECTED, with FAILED allowed from UPLOADING or TRANSCODING and up to three retries back to UPLOADING. Given a job's event sequence, report whether it is valid, and if not, the index and reason of the first bad event.
TikTok
November 29, 20260
0
0 solved
A video upload job moves through states CREATED, UPLOADING, UPLOADED, TRANSCODING, REVIEW and then PUBLISHED or REJECTED, with FAILED allowed from UPLOADING or TRANSCODING and up to three retries back to UPLOADING. Given a job's event sequence, report whether it is valid, and if not, the index and reason of the first bad event.
TikTok phone screens often open with a short simulation that mirrors backend work, here auditing the upload and moderation pipeline. The interviewer checks that you model the state machine as data rather than nested if statements, and that error reporting is precise enough to debug a real stuck job.
What the Interviewer Expects
- Encodes transitions as a table, not scattered conditionals
- Tracks auxiliary state (retry count) separately from the main state
- Returns the first failing index and a useful reason
- Treats terminal states as having no outgoing edges
- Handles an empty event list
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you validate millions of jobs from a Kafka topic where events can arrive out of order?
- How would you add a timeout rule, such as TRANSCODING must finish within 10 minutes?
- How would you generate a diagram or documentation from the same transition table?
- Where should this validation live: producer, consumer, or an offline audit?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is the list of states the job entered, in order, starting implicitly from CREATED. Valid edges: CREATED to UPLOADING; UPLOADING to UPLOADED or FAILED; UPLOADED to TRANSCODING; TRANSCODING to REV...
High-Level Design
Put the graph in a dictionary from state to the set of allowed next states. Walk the events with a current state and a retry counter. For each event, check membership in the allowed set; if the transi...