ByteDance Coding Interview Questions
25 ByteDance coding interview problems with full optimal solutions — 10 easy, 11 medium, 4 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an ByteDance interviewer values, and a FAQ section.
- #1easyfoundational
1. Two Sum
Find two indices in an array whose values sum to a target — a warm-up that ByteDance uses to gauge hash-map fluency before deeper recommendation pipeline questions.
- #2easyfoundational
2. Valid Parentheses
Verify a string of brackets is properly balanced — ByteDance leans on this to confirm stack fluency before pivoting to feed-ranking expression parsers.
- #3easyfoundational
3. Merge Two Sorted Lists
Stitch two sorted linked lists into one — ByteDance uses this to test pointer hygiene that maps directly to merging sorted candidate rankings.
- #4easyfoundational
4. Best Time to Buy and Sell Stock
Find the maximum profit from a single buy-sell pair — ByteDance uses it to test running-minimum bookkeeping before scaling to streaming ranking signals.
- #5easyfoundational
5. Maximum Subarray
Return the largest sum of a contiguous subarray — ByteDance asks this to confirm you reach Kadane's algorithm before tracing why it generalizes to engagement-score smoothing.
- #6easyfoundational
6. Reverse Linked List
Reverse a singly linked list in place — ByteDance uses it to verify pointer fluency before moving to feed-pipeline buffer questions.
- #7easyfoundational
7. Linked List Cycle
Detect whether a linked list contains a cycle — ByteDance uses it to confirm you reach Floyd's two-pointer trick before discussing content-graph traversal.
- #8easyfoundational
8. Climbing Stairs
Count distinct ways to climb n stairs taking 1 or 2 steps — ByteDance uses it to test the leap from recursion to DP before deeper ranking-DP problems.
- #9easyfoundational
9. Valid Palindrome
Determine if a string is a palindrome ignoring non-alphanumeric characters — ByteDance uses it as a moderation-pipeline warm-up before harder text-normalization questions.
- #10easyfoundational
10. Contains Duplicate
Return true if any value appears twice in the array — ByteDance uses it as a dedup warm-up before deeper content-fingerprinting questions.
- #11mediumfoundational
11. Add Two Numbers
Add two non-negative integers stored as reverse-order linked lists — ByteDance uses it to test edge-case pointer handling before deeper feed-pipeline questions.
- #12mediumfoundational
12. Longest Substring Without Repeating Characters
Find the longest substring with no repeating characters — ByteDance uses it to gauge sliding-window fluency before scaling to user-session deduplication.
- #13mediumfoundational
13. Container With Most Water
Pick two lines that hold the most water — ByteDance uses it to validate two-pointer reasoning before progressing to ranking-score gap problems.
- #14mediumfoundational
14. 3Sum
Return all unique triplets summing to zero — ByteDance uses it to test sort + two-pointer scaffolding and de-duplication discipline.
- #15mediumfoundational
15. Group Anagrams
Cluster anagrams into groups — ByteDance uses it to test hashable-canonical-form thinking before scaling to comment-clustering pipelines.
- #16mediumfoundational
16. Merge Intervals
Merge overlapping intervals into a minimal set — ByteDance uses it to test sort + sweep reasoning before scaling to watch-time aggregation problems.
- #17mediumfoundational
17. Word Break
Decide whether a string can be segmented into dictionary words — ByteDance uses it to probe DP intuition before deeper text-segmentation pipeline questions.
- #18mediumfoundational
18. LRU Cache
Design an LRU cache with O(1) get and put — ByteDance asks this nearly every loop because it mirrors how their video-thumbnail edge cache must evict cold tiles in microseconds.
- #19mediumfoundational
19. Top K Frequent Elements
Return the k most frequent elements in an array — ByteDance uses it as a direct proxy for top-K trending content selection in TikTok feeds.
- #20mediumfoundational
20. Kth Largest Element in an Array
Find the kth largest value in an unsorted array — ByteDance uses it to test heap vs quickselect tradeoffs that show up in their ranking-cutoff systems.
- #21mediumfoundational
21. Number of Islands
Count connected land regions in a grid — ByteDance uses it to test BFS/DFS scaffolding before scaling to user-cluster detection for recommendations.
- #22hardfoundational
22. Median of Two Sorted Arrays
Find the median of two sorted arrays in logarithmic time — ByteDance uses it to test binary-search-on-answer reasoning that mirrors quantile estimation in their ranking pipeline.
- #23hardfoundational
23. Trapping Rain Water
Compute the volume of rainwater trapped between bars of varying heights — ByteDance uses it to test two-pointer DP and bottleneck-thinking under pressure.
- #24hardfoundational
24. Merge k Sorted Lists
Merge k sorted linked lists into one sorted list — ByteDance uses it as a direct stand-in for merging k partitioned ranking streams into a single feed.
- #25hardfoundational
25. Sliding Window Maximum
Return the maximum of every sliding window of size k — ByteDance uses it because it mirrors how their ranking engine summarizes engagement signals over rolling windows.