Problem database last updated: June 20, 2025

BByteDance logo

ByteDance Coding Interview Questions

63 problems · 8 Easy, 48 Medium, 7 Hard · Ranked #39 of 458

Difficulty breakdown

8 Easy

13% · avg 23%

48 Medium

76% · avg 59%

7 Hard

11% · avg 18%

Top topics

array
52.4%
string
25.4%
dynamic-programming
23.8%
hash-table
20.6%
math
17.5%
two-pointers
12.7%

Interview profile

Based on 63 reported problems, ByteDance interviews are in line with industry averages - 11% Hard vs 18% overall. The majority (76%) 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, ByteDance puts unusual emphasis on merge-sort (3.2% of problems, 4.3x the industry average), quickselect (3.2% of problems, 3x the industry average), topological-sort (3.2% of problems, 2.7x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (52.4%), string (25.4%), dynamic-programming (23.8%), hash-table (20.6%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 63 problems

LRU Cache

Solve

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

MediumVery Likely
hash-tablelinked-listdesign

Smallest Subsequence of Distinct Characters

Solve

Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.

MediumVery Likely
stringstackgreedy

First Day Where You Have Been in All the Rooms

Solve

There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.

MediumVery Likely
arraydynamic-programming

Remove Duplicate Letters

Solve

Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical or...

MediumVery Likely
stringstackgreedy

Number of Islands

Solve

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

MediumVery Likely
arraydepth-first-searchbreadth-first-search

Course Schedule

Solve

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, b...

MediumVery Likely
depth-first-searchbreadth-first-searchgraph

Longest Substring Without Repeating Characters

Solve

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

MediumLikely
hash-tablestringsliding-window

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

Kth Largest Element in an Array

Solve

Given an integer array nums and an integer k, return the kth largest element in the array.

MediumLikely
arraydivide-and-conquersorting

Basic Calculator II

Solve

Given a string s which represents an expression, evaluate this expression and return its value.

MediumLikely
mathstringstack

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

Longest Consecutive Sequence

Solve

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

MediumLikely
arrayhash-tableunion-find

House Robber

Solve

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from rob...

MediumLikely
arraydynamic-programming

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.

HardLikely
arraytwo-pointersdynamic-programming

Search in Rotated Sorted Array

Solve

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

MediumLikely
arraybinary-search

House Robber II

Solve

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in...

MediumLikely
arraydynamic-programming

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...

MediumLikely
arraysorting

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

Insert Delete GetRandom O(1)

Solve

Implement the RandomizedSet class:

MediumLikely
arrayhash-tablemath

Maximal Square

Solve

Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

MediumLikely
arraydynamic-programmingmatrix

Longest Common Subsequence

Solve

Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

MediumLikely
stringdynamic-programming

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...

MediumLikely
linked-listmathrecursion

Basic Calculator

Solve

Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.

HardLikely
mathstringstack

Rotting Oranges

Solve

You are given an m x n grid where each cell can have one of three values:

MediumLikely
arraybreadth-first-searchmatrix

Sum Game

Solve

Alice and Bob take turns playing a game, with Alice starting first.

MediumLikely
mathstringgreedy

Number of Good Leaf Nodes Pairs

Solve

You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the sho...

MediumLikely
treedepth-first-searchbinary-tree

Sort List

Solve

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

MediumLikely
linked-listtwo-pointersdivide-and-conquer

Delete Operation for Two Strings

Solve

Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.

MediumLikely
stringdynamic-programming

Top K Frequent Elements

Solve

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

MediumLikely
arrayhash-tabledivide-and-conquer

Subarray Sum Equals K

Solve

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

MediumLikely
arrayhash-tableprefix-sum

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

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

Remove Zero Sum Consecutive Nodes from Linked List

Solve

Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences.

MediumSometimes
hash-tablelinked-list

Climbing Stairs

Solve

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

EasySometimes
mathdynamic-programmingmemoization

Longest Palindromic Substring

Solve

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

MediumSometimes
two-pointersstringdynamic-programming

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...

EasySometimes
arraytwo-pointerssorting

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]).

MediumSometimes
arraytwo-pointersgreedy

Reverse Linked List

Solve

Given the head of a singly linked list, reverse the list, and return the reversed list.

EasySometimes
linked-listrecursion

Next Permutation

Solve

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

MediumSometimes
arraytwo-pointers

Peak Index in a Mountain Array

Solve

You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease.

MediumSometimes
arraybinary-search

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...

MediumSometimes
mathdynamic-programmingcombinatorics

Pow(x, n)

Solve

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

MediumSometimes
mathrecursion

Decode String

Solve

Given an encoded string, return its decoded string.

MediumSometimes
stringstackrecursion

Subsets

Solve

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

MediumSometimes
arraybacktrackingbit-manipulation

Merge k Sorted Lists

Solve

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

HardSometimes
linked-listdivide-and-conquerheap-priority-queue

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

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...

HardSometimes
hash-tablestringsliding-window

Course Schedule II

Solve

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, b...

MediumSometimes
depth-first-searchbreadth-first-searchgraph

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

Design Memory Allocator

Solve

You are given an integer n representing the size of a 0-indexed memory array. All memory units are initially free.

MediumSometimes
arrayhash-tabledesign

Search a 2D Matrix II

Solve

Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties:

MediumSometimes
arraybinary-searchdivide-and-conquer

Add to Array-Form of Integer

Solve

The array-form of an integer num is an array representing its digits in left to right order.

EasySometimes
arraymath

Open the Lock

Solve

You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely...

MediumSometimes
arrayhash-tablestring

Trapping Rain Water II

Solve

Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining.

HardSometimes
arraybreadth-first-searchheap-priority-queue

Longest Repeating Character Replacement

Solve

You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform th...

MediumSometimes
hash-tablestringsliding-window

Sum of Distances in Tree

Solve

There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.

HardSometimes
dynamic-programmingtreedepth-first-search

Minimum Area Rectangle

Solve

You are given an array of points in the X-Y plane points where points[i] = [xi, yi].

MediumSometimes
arrayhash-tablemath

H-Index

Solve

Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index.

MediumSometimes
arraysortingcounting-sort

Find All Good Indices

Solve

You are given a 0-indexed integer array nums of size n and a positive integer k.

MediumSometimes
arraydynamic-programmingprefix-sum

Degree of an Array

Solve

Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.

EasySometimes
arrayhash-table

Count Binary Substrings

Solve

Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings...

EasySometimes
two-pointersstring

Maximum Value at a Given Index in a Bounded Array

Solve

You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:

MediumSometimes
mathbinary-searchgreedy

Partition to K Equal Sum Subsets

Solve

Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.

MediumSometimes
arraydynamic-programmingbacktracking

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 ByteDance interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your ByteDance coding interview

ByteDance 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. ByteDance 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 ByteDance ask in interviews?add

ByteDance has been reported to ask 63 distinct coding problems. The most common topics are array, string, dynamic-programming. 8 are Easy difficulty, 48 are Medium, and 7 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are ByteDance coding interviews?add

Based on 63 reported problems, ByteDance interviews are in line with industry averages - 11% Hard vs 18% overall. 76% 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 ByteDance 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 ByteDance interview?

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

Simulate a ByteDance interview with AIarrow_forward