I just finished a walk with students TikTok 2026 Intern SDE OA. The pace of the entire exam is actually quite fast. The four questions are basically typical algorithm/simulation question types. If you can answer the questions normally, you can basically respond to the ideas quickly.
The overall time this time is not long. The first two questions are relatively basic implementation questions. The last two questions require a little more thinking, but they are not particularly complicated. When the student first copied the code for the third question, he made a small mistake. However, he checked it out in time and corrected it, and he successfully passed the exam. The last four questions were all passed.
Let’s briefly sort out the question types and core ideas for reference by students preparing for TikTok OA later.

Q1 Draw a square with an asterisk border
Question description
The first question is a typical output simulation question. The question is given an integer N, request to print a N×n Of a square where the border uses *, the middle part is a space, which is a common "hollow square".
For example N=5 , the output structure is roughly as follows:
*****
* *
* *
* *
*****
The overall requirement is to fill the four sides of the square with asterisks, while leaving the middle area empty.
Problem-solving ideas
Implementation can be accomplished through two levels of loops. The outer loop controls the number of rows, and the inner loop controls the number of columns. For every location (i,j), determine the output content based on whether it is located on the boundary.
When the line number is the first or last line, the entire line is output *. If it is a middle row, only the first and last columns are output. *, all spaces in the middle are output. This will form a complete border structure.
A special case needs to be noted: if N=1, you only need to output one * That’s it. The overall difficulty of this question is very basic, mainly examining loop control and output format.
Q2 Calculation of round trip time between the two cities
Question description
The second question begins to enter the simulation type questions. The question is given the departure timetable between two cities, and there is a fixed departure time list in each direction. Passengers need to constantly travel between the two cities.
The rule is that every time you take a bus, you must choose a bus with a departure time no earlier than the current time. The ride takes 100 minutes (including travel and transfers) and then you need to continue on to the next bus from another city.
The goal of the question is to simulate the entire round trip process based on these timetables.
Problem-solving ideas
The core of this question is actually time-advance simulation. We can maintain a current time T, every time you prepare to take a bus, you must find the first train with a departure time greater than or equal to the current time in the current direction timetable.
After finding this bus, you can update the current time to Departure + 100. Then switch directions and continue looking for the next bus from another city's timetable.
If the timetable is a sorted array, you can use a binary search to find the next bus (e.g. Lower_bound). In this way, the time complexity of each search is O(log n), the overall efficiency will be higher.
Q3 Minimum peak height difference
Question description
The third question is an array type question. The question is given an array Height Represents the height of the mountain and gives an integer K, represents the minimum index distance between two peaks.
Requirements met in all |i - j| ≥ k Pair up the peaks, find the pair with the smallest height difference, and output the smallest difference.
In other words, all legal (i,j) In combination, calculate |height[i] - height[j]|, and then take the minimum value.
Problem-solving ideas
The most direct method is to enumerate all pairs of peaks that meet the conditions. The array can be traversed through two levels of loops, respectively as I And J. When traversing, you only need to determine whether the index difference between the two is satisfied. |i - j| ≥ k.
If the conditions are met, the height difference between the two peaks is calculated and the current minimum value is updated. The whole process is actually a simple violent enumeration.
The time complexity of this method is O(n²). If the array size is not particularly large, it is usually passable in OA. In theory, further optimization can be done through methods such as sorting or sliding windows, but in most cases this is not needed.
Q4 flight round trip mission simulation
Question description
The structure of the fourth question is actually very similar to the second question. It is also a time simulation question. The question is given two locations: Alpha and Beta, and flight schedules in both directions are given.
Each task requires a round trip, that is:
Alpha → Beta → Alpha
And the task needs to be repeated multiple times.
Problem-solving ideas
The problem-solving idea is still to simulate time advancement. We first maintain a current time T. Every time you depart from Alpha, you need to find the earliest flight whose departure time is no earlier than the current time in the flight list of Alpha → Beta.
After taking this flight, the current time is updated to the arrival time. Then search again for the next eligible flight in the flight list from Beta → Alpha. After completing these two steps, a round trip mission is completed.
Then continue to repeat this process until all tasks are completed. If the flight schedule is in order, binary search can also be used to quickly locate the next flight, so that the entire simulation process will be more efficient.
OA jamming is actually quite common.
We usually take students here to do actual OA simulations of TikTok / Amazon / Google / Uber. If you are not familiar with this kind of OA or are worried about performing on the spot, you can also learn about our interview assistance / OA real-time assists , to give you some reminders at critical moments. This is how many students successfully pass OA.