Just finished it recently TikTok Online Assessment. I usually practice CodeSignal's GCF question bank more frequently, and this time I only took 13 minutes to complete all four questions. Everyone should know that TikTok OA is very hard to brush people off, but as long as you master the routine, the difficulty is actually just that. To help you avoid pitfalls, I have compiled this practical experience.
Personal background
Education: Currently studying for a master's degree in computer science at the University of Southern California (USC).
Experience: 1.5 years of Internet backend internship/development experience.
TikTok’s questions are actually very similar to the logic of byte internal push. The core is speed and accuracy. CodeSignal has speed points, so it is recommended that everyone be familiar with the basic templates.

TikTok OA basic situation
Platform: CodeSignal
Duration: 70 minutes
Number of questions: 4 questions
Difficulty structure:
- Q1: Easy (simulation)
- Q2: Easy–Mid (prefix / Trie)
- Q3: Mid (string simulation)
- Q4: Mid (thinking question, random)
Suggested tempo:
- Q1: 10–15 minutes
- Q2:15 minutes
- Q3:10 minutes
- Q4: Remaining time
Try to finish the first three questions within 45 minutes, otherwise you will be very rushed later.
Topic 1: Distribution center scheduling problem
You manage a network of distribution centers that handle package deliveries. Each center has a different package handling capacity before needing to be reset.
Input parameters
CenterCapacities: an integer array,CenterCapacities[i]The value is between 1 and 5, indicating the maximum number of packages that the i-th distribution center can handle before maintenance is required.DailyLog:A string array,DailyLog[i]One of the following two operations:"PACKAGE": There is a new package to process"CLOSURE ": The jth distribution center is temporarily closed due to maintenance
Package allocation rules
- Packages are distributed to the various distribution centers in sequence: each center handles the packages within its capacity, and when full, the packages are sent to the next available center.
- After a complete round of traversing all centers (returning to center 0), the capacities of all operating centers will be reset to their initial values; however, closed centers will still be unavailable.
- The system automatically skips closed centers when allocating packages.
- The question ensures that at least one center is always in operation during the entire process.
Output requirements
Returns the index of the distribution center that handles the highest number of packages. If multiple centers have the largest number of packages processed, the one with the largest index is returned.
Complexity requirements
The time complexity does not exceed O(centerCapacities.length × dailyLog.length) You can pass.
Example
- Enter:
CenterCapacities = [1, 2, 1, 2, 1]DailyLog = ["PACKAGE", "PACKAGE", "CLOSURE 2", "PACKAGE", "CLOSURE 3", "PACKAGE", "PACKAGE"] - Explain:
- Package 1: Center 0 processed (capacity reached), number of processed:
[1,0,0,0,0], remaining capacity:[0,2,1,2,1] - Parcel 2: Center 1 Handling, Handles:
[1,1,0,0,0], remaining capacity:[0,1,1,2,1] CLOSURE 2: Center 2 closed- Parcel 3: Center 1 handled (still capacity), number of handles:
[1,2,0,0,0], remaining capacity:[0,0,1,2,1] CLOSURE 3: Center 3 closed- Parcel 4: Skip centers 2, 3, assigned to center 4, handles:
[1,2,0,0,1], remaining capacity:[0,0,1,2,0] - One round of traversal of all operation centers ends and the capacity is reset: the remaining capacity is restored to
[1,2,1,2,1](Centers 2 and 3 remain closed) - Parcel 5: assigned to center 0, number of processes:
[2,2,0,0,1], remaining capacity:[0,2,1,2,1]
- Package 1: Center 0 processed (capacity reached), number of processed:
- Output:
1(Both center 0 and center 1 process 2 packages, take center 1 with a larger index)
Problem-solving ideas
- Maintain
Remaining[](remaining capacity),Processed[](total number processed),Closed[](closed status) - Use pointers
CurRecord current assigned location - Key: End of round judgment - when the pointer wraps around to 0 from somewhere (that is, a complete traversal is completed), reset the capacity of all operation centers
- Eventually return
ProcessedThe maximum index corresponding to the maximum value in
Question 2: The longest common prefix length problem
Given two arrays of numbers FirstArray And SecondArray, find: the length of the longest common prefix (LCP) among all pairs of numbers formed by taking a number from each of the two arrays. If no common prefix exists, 0 is returned.
Illustrate
- Prefix of a number: consists of one or more digits of a number, starting with the highest digit. For example
123Yes12345The prefix,2Yes234Prefix. - Common prefix of two numbers: A number that is the prefix of both numbers. For example
5655359And56554The longest common prefix of is5655(length 4);123And456There is no common prefix.
Input parameters
FirstArray: Positive integer array, length range[1, 5×10⁴], element range[1, 10⁹]SecondArray: Positive integer array, length range[1, 5×10⁴], element range[1, 10⁹]
Output requirements
Returns the length of the longest common prefix among all pairs spanning arrays; if there is no common prefix, returns 0.
Example
- Enter:
FirstArray = [25, 288, 2655, 54546, 54, 555]SecondArray = [2, 255, 266, 244, 26, 5, 54547]Output:4Explain:FirstArrayIn54546AndSecondArrayIn54547The longest common prefix of is5454, length is 4. - Enter:
FirstArray = [25, 288, 2655, 544, 54, 555]SecondArray = [2, 255, 266, 244, 26, 5, 5444444]Output:3Explain:FirstArrayIn544AndSecondArrayIn5444444The longest common prefix of is544, length is 3. - Enter:
FirstArray = [817]SecondArray = [1999, 1909]Output:0Explanation: There is no common prefix for any number pairs in the two arrays.
Problem-solving ideas
Brute force O(N×M×L) will time out. Core optimization: using Trie (prefix tree)
- Will
FirstArrayEach prefix (in string form) of all numbers in is stored in the hash set - Traverse
SecondArrayFor all prefixes of each number in the set, find whether they exist in the set and take the maximum matching length.
Time complexity: O((N + M) × L), L is the maximum number length (≤10), which fully meets the requirements.
Topic 3: Bit addition problem of digital strings
Given two strings consisting only of numbers, without leading zeros A And B, processed according to the following rules:
Starting at the end of both strings, add each digit:
- Pick
AThe i-th last digit of , plusBThe i-th digit from the bottom of - If the i-th digit from the bottom of one of the strings does not exist, only the i-th digit from the bottom of the other string is taken.
- Concatenate the sum of each bit into a new string and return
Input parameters
A: Numeric string, containing only numbers, no leading zerosB: Numeric string, containing only numbers, no leading zeros
Output requirements
Returns the string concatenated according to the above rules.
Example
- Enter:
A = "99",B = "99"Output:"1818"Explanation: 1st from last9+9=18, 2nd from last9+9=18, the splicing result is1818. - Enter:
A = "11",B = "9"Output:"110"Explanation: 1st from last1+9=10, 2nd from last1(B(no corresponding bit), the splicing result is110.
Problem-solving ideas
- Double pointers move forward from the end
- Take the corresponding bit at each step (if the other one does not exist, take 0), sum and convert to a string
- Collect the results of each step and reverse the splicing (because processing starts from the end)
Question 4: The graceful sum of the largest continuous subarray
Give you an array of integers Nums, define beautiful numbers: a number consists only of even numbers (0, 2, 4, 6, 8), excluding 1, 3, 5, 7, and 9.
For example: 2, 48, 206, and 88 are beautiful numbers; 12, 23, and 5 are not beautiful numbers.
Rule
- Only select consecutive subarrays in which all elements in the array are beautiful numbers;
- Find the sum of elements of all consecutive subarrays that meet the conditions and return the maximum sum;
- If there are no graceful numbers in the array, 0 is returned.
Enter
Integer array Nums, element range -1000 ~ 1000, array length 1 ≤ n ≤ 1000
Output
Maximum sum of a continuous subarray of fully graceful numbers that meets the conditions
Example
Example 1:
Enter:Nums = [28, 40, 13, 68, 7]
Explain:
[28,40] are both beautiful numbers, and sum = 68
[68] and = 68
The maximum sum is 68
Output: 68
Example 2:
Enter:Nums = [12, 35, 79]
There is no graceful number, output: 0
Example 3:
Enter:Nums = [8, 24, -4, 66]
The whole paragraph is a beautiful number, sum = 94
Output: 94
Problem-solving ideas
- First write a judgment function: pass in an integer and judge whether each digit is an even number (0, 2, 4, 6, 8) to judge whether it is a beautiful number.
- Traverse the array and use continuous sub-arrays to slide the idea:
- Graceful numbers encountered: Accumulate current consecutive sums.
- Non-graceful numbers: break continuity and reset the current sum to 0.
- The global maximum sum is continuously updated throughout the process.
- If there is no graceful number at the end, 0 is returned, otherwise the maximum sum is returned.
TikTok Online Assessment preparation experience and practical suggestions
- CodeSignal score moisture: Don't just go for AC, go for fast AC. The same Full Score, completed in 15 minutes and completed in 70 minutes, has different weights in HR.
- Key points to brush up on: Focus on CodeSignal Industry Coding Framework, especially the part about simulation and DP.
Don’t let the freezing period delay your dream of becoming a big factory
Facing a top company like TikTok, the cost of trial and error is extremely high (there is usually a 6-month freezing period once it fails). If you're not 100% sure about your OA stability, or feel stressed about your real-time thinking during interviews, I highly recommend understanding ProgramHelp Auxiliary services:
- OA invisible ghostwriting: Original handwritten code, traceless inspection, ensuring 100.
- VO real-time assistance: Senior SDE tutors in North America are online and provide real-time problem-solving logic and coding ideas during interviews to help you conquer the interviewer.
- Full process support: From resume packaging to onboarding guidance after landing, we provide real "accompanying" services.
The workplace is not just about hard work. Reasonable "external forces" can help you reduce your dimensionality in the fierce competition.