TikTok 2026 OA full analysis: Codesignal real questions, Python AC solutions

84 Views
No Comment

As a professional team focused on job search assistance, programhelp has recently tracked many TikTok For the OA written test for school recruitment and social recruitment, it was found that the test format has undergone major adjustments: the platform has been fully migrated from the original HackerRank to Codesignal, and the question type has also been changed from "5 choices + 2 programming" to "4 pure programming questions in 70 minutes." At present, platforms such as One Acre Three Minutes rarely share the latest original questions. Based on recent practical experience, we have compiled a complete analysis of the real questions, AC solutions and targeted coaching programs to help job seekers pass the test efficiently.

核心考试信息梳理

  1. Exam platform: Codesignal web version only, supports local IDE writing and pasting and submission, and provides code highlighting and running debugging functions;
  2. Question type rules: 4 pure programming questions, no multiple choice questions, 70 minutes to answer, plenty of time, and there is still enough time to check for errors after completing at a moderate speed;
  3. Source of question bank: Do not use TikTok’s self-developed question bank, all questions are extracted from the Codesignal platform’s native questions, no repeated old questions, focusing on testing hard skills;
  4. 通过标准:题目难度整体为中等,无高难度 Hard 题,4 道题全部 AC(100% 通过率)是获取面试邀约的关键,仅通过 2-3 道则通过率大幅下降;
  5. Distribution of test points: Focus on array string processing, simulation logic, and hash table applications. There are no complex DP or graph theory questions. It is a type that can be overcome through system training.

Real question 1: Digital fragment splicing statistics (high-frequency must test)

Question description

Given the positive integer array fragments (number fragments) and the target number accessCode, count the number of ordered subscript pairs (i, j) (i≠j) that meet the condition, requiring str (fragments [i]) + str (fragments [j]) == str (accessCode).

Problem-solving ideas

The optimal solution to this problem is string processing combined with a hash table, with a time complexity of O (n) to avoid timeout caused by violent enumeration:

  1. Type conversion: Convert accessCode to string s, and all numeric fragments in the array are converted to string form;
  2. Frequency statistics: Use Counter to count the occurrence times of all string fragments to facilitate quick query;
  3. Prefix matching: Traverse each string fragment a, determine whether s is prefixed by a, and if so, calculate the suffix b = s [len (a):];
  4. Calculation of the number of combinations: If b exists in the statistical results, it is calculated in two cases: when a≠b, the number of combinations is the frequency of a × the frequency of b; when a==b, i≠j must be satisfied, and the number of combinations is the frequency of a × (the frequency of a – 1);
  5. Accumulation of results: Summarize the number of all eligible combinations to get the final answer.

AC full score code (Python, Codesignal direct submission)

Python

Run

From collections import Counter

def solution(fragments, accessCode):
    s = str(accessCode)
    str_frags = [str(num) for num in fragments]
    cnt = Counter(str_frags)
    res=0
    for a in cnt:
        if s.startswith(a):
            b = s[len(a):]
            if b in cnt:
                if a != b:
                    res += cnt[a] * cnt[b]
                else:
                    res += cnt[a] * (cnt[a] - 1)
    return res

Reminder of easy mistakes

  1. Pay attention to the ordered pair requirements. The solution naturally covers the order difference between i and j without additional processing;
  2. It must be judged by string concatenation, and digital operations cannot be performed directly to avoid errors caused by carry-over of digits;
  3. Focus on the scenario where a==b, missing “frequency – 1” will lead to a smaller answer.

Real question 2: Newspaper layout (text alignment + border simulation)

Question description

Given a word array, page width width, and alignment (left/right), complete typesetting and return the complete page according to the following rules:

  1. Typesetting rules: Load words in order, leaving at least 1 space between words. If adding the next word will exceed the width, wrap the word;
  2. Alignment rules: Each line of content is padded with spaces to the length of width, left-aligned to pad the tail, and right-aligned to pad the beginning;
  3. Border rules: add vertical lines | at the beginning and end of each line, and add horizontal lines - with a width of width+2 at the top and bottom of the page. Supplementary constraints: The length of a single word does not exceed width, and there is no typesetting difficulty.

Problem-solving ideas

This question is a pure simulation question. The core lies in logical disassembly and detail processing. The steps are as follows:

  1. Line processing: traverse the words, accumulate the length of the word in the current line and the number of spaces required, and determine whether the next word can be added. If not, process the current line and wrap it in a new line;
  2. Alignment and completion: After splicing each line of words, calculate the number of required supplementary spaces and complete the space filling according to the alignment;
  3. Border addition: Add | to the beginning and end of each line of content to generate upper and lower horizontal borders, which are combined into the final page.

AC full score code (Python, Codesignal direct submission)

Python

Run

Def solution(words, width, alignment):
    lines = []
    current_line = []
    for word in words:
        current_len = sum(len(w) for w in current_line) + len(current_line) - 1 + len(word) if current_line else len(word)
        if current_len <= width:
            current_line.append(word)
        else:
            lines.append(' '.join(current_line))
            current_line = [word]
    if current_line:
        lines.append(' '.join(current_line))
    
    border_lines = []
    for line in lines:
        space_need = width - len(line)
        if alignment == 'left':
            aligned = line + ' ' * space_need
        else:
            aligned = ' ' * space_need + line
        border_lines.append(f'|{aligned}|')
    
    top_bottom_border = '-' * (width + 2)
    final = [top_bottom_border] + border_lines + [top_bottom_border]
    return '\n'.join(final)

Reminder of easy mistakes

  1. The spaces between words must be included when calculating line breaks, otherwise it will lead to incorrect line break judgment;
  2. The space supplement must be accurate to the width length to avoid border misalignment;
  3. After the traversal is completed, the unsaved words in the last line need to be processed.

高频补充真题

第一题:找所有 t[i] > t[i – 1] && t[i] > t[i + 1] 的数,然后返回这个数组就行了,按题意模拟一遍

第二题:维护每个位置放了多少种不同的物品,返回物品数量最多的位置,需要用 map 套 set 来维护位置并且给物品去重,最后遍历我们的 map 还有 set 的 size 大小就行了,记录最大值

第三题:我们以每个 1 为起始点,按题目意思模拟,向左上右上左下右下拓展就行了,对应的每次 x y 坐标的增量向量就是 (1, 1) (1, -1) (-1, -1), (-1, 1) 这四种,跑一遍就行了,注意只有走到边界才计入答案当中

第四题:维护每个点被多少个 2 * 2 的矩阵覆盖,如果建一个 n * m 的矩阵然后模拟肯定不行,因为 n m 大小的规模都是 1e5 的,但是由于每个点最多被覆盖 4 次,并且 2 *2 矩阵的数量是有限的,我们直接用 map 来维护,维护每个点的状态,这里的话懒得再写个 pair 插到 map 里了,就直接写个状压得了,由于 (x, y) 都是不超过 int 范围的,所以我们可以用 x << 32 再或上 y 来得到这个点的状态,然后在 map 里对应点的计数++就好了,最后 0 的数量用总的算算就行

How to clear TikTok OA efficiently?Programhelp Help you!

Faced with TikTok’s school recruitment/social recruitment OA, relying solely on answering questions is often inefficient and easy to miss details.Programhelp Provide remote invisible OA writing and online tutoring services, covering mainstream platforms such as HackerRank, Niuke.com, and Codesignal.

  • OA ghostwriting: Guarantee that all test cases pass 100%, no fee will be charged if they fail;
  • AC solution coaching: Python, Java, C++ and other languages ​​are available, and the core logic and error-prone points of each question are accurately explained;
  • Remote invisible operation: Completely safe and does not affect account use;
  • Personalized training: Customize the test plan based on your weaknesses to quickly improve the efficiency of clearance.

No longer fighting alone, Programhelp allows you to efficiently pass TikTok OA and easily move towards interview offers.

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END
 0