Problem database last updated: June 20, 2025

TTikTok logo

TikTok Coding Interview Questions

98 problems · 13 Easy, 66 Medium, 19 Hard · Ranked #16 of 458

Difficulty breakdown

13 Easy

13% · avg 23%

66 Medium

67% · avg 59%

19 Hard

19% · avg 18%

Top topics

array
51%
string
30.6%
dynamic-programming
25.5%
hash-table
18.4%
two-pointers
16.3%
backtracking
13.3%2.5x

Interview profile

Based on 98 reported problems, TikTok interviews are in line with industry averages - 19% Hard vs 18% overall. The majority (67%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, TikTok puts unusual emphasis on merge-sort (2% of problems, 2.8x the industry average), binary-search-tree (3.1% of problems, 2.7x the industry average), backtracking (13.3% of problems, 2.5x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (51%), string (30.6%), dynamic-programming (25.5%), hash-table (18.4%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 98 problems

LRU Cache

Solve

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

MediumVery Likely
hash-tablelinked-listdesign

Merge Intervals

Solve

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cove...

MediumVery Likely
arraysorting

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumVery Likely
hash-tablestringsliding-window

Trapping Rain Water

Solve

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

HardVery Likely
arraytwo-pointersdynamic-programming

Minimum Window Substring

Solve

Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is inc...

HardVery Likely
hash-tablestringsliding-window

Merge k Sorted Lists

Solve

You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.

HardVery Likely
linked-listdivide-and-conquerheap-priority-queue

Word Search

Solve

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

MediumVery Likely
arraystringbacktracking

Search in Rotated Sorted Array

Solve

There is an integer array nums sorted in ascending order (with distinct values).

MediumVery Likely
arraybinary-search

Longest Palindromic Substring

Solve

Given a string s, return the longest palindromic substring in s.

MediumLikely
two-pointersstringdynamic-programming

N-Queens

Solve

The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

HardLikely
arraybacktracking

Restore IP Addresses

Solve

A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros.

MediumLikely
stringbacktracking

Combination Sum

Solve

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum...

MediumLikely
arraybacktracking

3Sum

Solve

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

MediumLikely
arraytwo-pointerssorting

Word Ladder

Solve

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:

HardLikely
hash-tablestringbreadth-first-search

Sqrt(x)

Solve

Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.

EasyLikely
mathbinary-search

Best Time to Buy and Sell Stock

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

EasyLikely
arraydynamic-programming

Text Justification

Solve

Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justifie...

HardLikely
arraystringsimulation

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasyLikely
stringstack

Find Peak Element

Solve

A peak element is an element that is strictly greater than its neighbors.

MediumLikely
arraybinary-search

Spiral Matrix

Solve

Given an m x n matrix, return all elements of the matrix in spiral order.

MediumLikely
arraymatrixsimulation

Two Sum

Solve

Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target.

EasyLikely
arrayhash-map

Binary Tree Maximum Path Sum

Solve

A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequ...

HardLikely
dynamic-programmingtreedepth-first-search

Sort Colors

Solve

Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order...

MediumLikely
arraytwo-pointerssorting

Word Break II

Solve

Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possi...

HardLikely
arrayhash-tablestring

Construct Binary Tree from Preorder and Inorder Traversal

Solve

Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, c...

MediumLikely
arrayhash-tabledivide-and-conquer

Generate Parentheses

Solve

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

MediumLikely
stringdynamic-programmingbacktracking

Edit Distance

Solve

Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.

MediumLikely
stringdynamic-programming

Combination Sum II

Solve

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to...

MediumLikely
arraybacktracking

Permutations

Solve

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

MediumLikely
arraybacktracking

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumLikely
arraydivide-and-conquerdynamic-programming

Find First and Last Position of Element in Sorted Array

Solve

Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

MediumLikely
arraybinary-search

Regular Expression Matching

Solve

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '' where:

HardLikely
stringdynamic-programmingrecursion

Container With Most Water

Solve

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

MediumLikely
arraytwo-pointersgreedy

Word Break

Solve

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.

MediumLikely
arrayhash-tablestring

Reverse Nodes in k-Group

Solve

Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.

HardLikely
linked-listrecursion

Longest Consecutive Sequence

Solve

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

MediumLikely
arrayhash-tableunion-find

Jump Game

Solve

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length...

MediumLikely
arraydynamic-programminggreedy

Best Time to Buy and Sell Stock II

Solve

You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

MediumLikely
arraydynamic-programminggreedy

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumLikely
arrayhash-tablestring

Merge Sorted Array

Solve

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and num...

EasyLikely
arraytwo-pointerssorting

Decode Ways

Solve

You have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping:

MediumLikely
stringdynamic-programming

Subsets

Solve

Given an integer array nums of unique elements, return all possible subsets (the power set).

MediumLikely
arraybacktrackingbit-manipulation

Longest Common Prefix

Solve

Write a function to find the longest common prefix string amongst an array of strings.

EasyLikely
arraystringtrie

Next Permutation

Solve

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.

MediumLikely
arraytwo-pointers

Validate Binary Search Tree

Solve

Given the root of a binary tree, determine if it is a valid binary search tree (BST).

MediumLikely
treedepth-first-searchbinary-search-tree

Unique Binary Search Trees

Solve

Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n.

MediumLikely
mathdynamic-programmingtree

Reorder List

Solve

You are given the head of a singly linked-list. The list can be represented as:

MediumLikely
linked-listtwo-pointersstack

Parallel Courses III

Solve

You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [...

HardSometimes
arraydynamic-programminggraph

Surrounded Regions

Solve

You are given an m x n matrix board containing letters 'X' and 'O', capture regions that are surrounded:

MediumSometimes
arraydepth-first-searchbreadth-first-search

Median of Two Sorted Arrays

Solve

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

HardSometimes
arraybinary-searchdivide-and-conquer

Permutations II

Solve

Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

MediumSometimes
arraybacktrackingsorting

Minimum Path Sum

Solve

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.

MediumSometimes
arraydynamic-programmingmatrix

Integer to Roman

Solve

Seven different symbols represent Roman numerals with the following values:

MediumSometimes
hash-tablemathstring

Sort List

Solve

Given the head of a linked list, return the list after sorting it in ascending order.

MediumSometimes
linked-listtwo-pointersdivide-and-conquer

Find All Possible Recipes from Given Supplies

Solve

You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i],...

MediumSometimes
arrayhash-tablestring

Climbing Stairs

Solve

You are climbing a staircase. It takes n steps to reach the top.

EasySometimes
mathdynamic-programmingmemoization

Binary Tree Level Order Traversal

Solve

Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).

MediumSometimes
treebreadth-first-searchbinary-tree

Compare Version Numbers

Solve

Given two version strings, version1 and version2, compare them. A version string consists of revisions separated by dots '.'. The value of the revision is its i...

MediumSometimes
two-pointersstring

Step-By-Step Directions From a Binary Tree Node to Another

Solve

You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing...

MediumSometimes
stringtreedepth-first-search

Longest Valid Parentheses

Solve

Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.

HardSometimes
stringdynamic-programmingstack

Find Minimum in Rotated Sorted Array

Solve

Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:

MediumSometimes
arraybinary-search

Reverse Linked List II

Solve

Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right,...

MediumSometimes
linked-list

Reverse Words in a String

Solve

Given an input string s, reverse the order of the words.

MediumSometimes
two-pointersstring

Add Two Numbers

Solve

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a sing...

MediumSometimes
linked-listmathrecursion

Maximum Product Subarray

Solve

Given an integer array nums, find a subarray that has the largest product, and return the product.

MediumSometimes
arraydynamic-programming

Jump Game II

Solve

You are given a 0-indexed array of integers nums of length n. You are initially positioned at index 0.

MediumSometimes
arraydynamic-programminggreedy

Merge Two Sorted Lists

Solve

You are given the heads of two sorted linked lists list1 and list2.

EasySometimes
linked-listrecursion

Intersection of Two Linked Lists

Solve

Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at al...

EasySometimes
hash-tablelinked-listtwo-pointers

Multiply Strings

Solve

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.

MediumSometimes
mathstringsimulation

Fraction to Recurring Decimal

Solve

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

MediumSometimes
hash-tablemathstring

Distinct Subsequences

Solve

Given two strings s and t, return the number of distinct subsequences of s which equals t.

HardSometimes
stringdynamic-programming

Pow(x, n)

Solve

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

MediumSometimes
mathrecursion

Valid Palindrome

Solve

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forwa...

EasySometimes
two-pointersstring

Simplify Path

Solve

You are given an absolute path for a Unix-style file system, which always begins with a slash '/'. Your task is to transform this absolute path into its simplif...

MediumSometimes
stringstack

Spiral Matrix II

Solve

Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.

MediumSometimes
arraymatrixsimulation

Find Target Indices After Sorting Array

Solve

You are given a 0-indexed integer array nums and a target element target.

EasySometimes
arraybinary-searchsorting

Path Sum II

Solve

Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path...

MediumSometimes
backtrackingtreedepth-first-search

Best Time to Buy and Sell Stock III

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

HardSometimes
arraydynamic-programming

Remove Duplicates from Sorted Array II

Solve

Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative or...

MediumSometimes
arraytwo-pointers

Binary Tree Zigzag Level Order Traversal

Solve

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level...

MediumSometimes
treebreadth-first-searchbinary-tree

Insert Interval

Solve

You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and interv...

MediumSometimes
array

Word Ladder II

Solve

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:

HardSometimes
hash-tablestringbacktracking

Valid Sudoku

Solve

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

MediumSometimes
arrayhash-tablematrix

Maximal Rectangle

Solve

Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.

HardSometimes
arraydynamic-programmingstack

Plus One

Solve

You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most sig...

EasySometimes
arraymath

Swap Nodes in Pairs

Solve

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only...

MediumSometimes
linked-listrecursion

Path Sum

Solve

Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equa...

EasySometimes
treedepth-first-searchbreadth-first-search

4Sum

Solve

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

MediumSometimes
arraytwo-pointerssorting

Linked List Cycle II

Solve

Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.

MediumSometimes
hash-tablelinked-listtwo-pointers

Unique Paths

Solve

There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner...

MediumRare
mathdynamic-programmingcombinatorics

Subsets II

Solve

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

MediumRare
arraybacktrackingbit-manipulation

First Missing Positive

Solve

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums.

HardRare
arrayhash-table

Clone Graph

Solve

Given a reference of a node in a connected undirected graph.

MediumRare
hash-tabledepth-first-searchbreadth-first-search

Sum of Subarray Ranges

Solve

You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.

MediumRare
arraystackmonotonic-stack

Divide Two Integers

Solve

Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator.

MediumRare
mathbit-manipulation

Recover Binary Search Tree

Solve

You are given the root of a binary search tree (BST), where the values of exactly two nodes of the tree were swapped by mistake. Recover the tree without changi...

MediumRare
treedepth-first-searchbinary-search-tree

Interleaving String

Solve

Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.

MediumRare
stringdynamic-programming

Valid Number

Solve

Given a string s, return whether s is a valid number.

HardRare
string

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent TikTok interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your TikTok coding interview

TikTok interviews focus heavily on array, string, dynamic-programming problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. TikTok interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does TikTok ask in interviews?add

TikTok has been reported to ask 98 distinct coding problems. The most common topics are array, string, dynamic-programming. 13 are Easy difficulty, 66 are Medium, and 19 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are TikTok coding interviews?add

Based on 98 reported problems, TikTok interviews are in line with industry averages - 19% Hard vs 18% overall. 67% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a TikTok coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, dynamic-programming. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your TikTok interview?

Simulate a real TikTok coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a TikTok interview with AIarrow_forward