ByteDance Software Engineer Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Implement an LRU cache
Problem: LRU Cache Design and implement a data structure that supports an LRU (Least Recently Used) cache with a fixed capacity. Requirements Implemen...
Compute length of longest increasing subsequence
You are given an integer array nums of length n. A subsequence of nums is a sequence that can be derived from nums by deleting zero or more elements w...
Solve pair-counting and account-merging problems
Problem A — Count qualifying products You are given two integer arrays A and B, and an integer T. For each element a in A, count how many elements b i...
Find kth smallest in sorted 2D matrix
You are given an n x m matrix of integers where each row and each column is sorted in non-decreasing order. You are also given an integer k such that ...
Compute maximum path sum in binary tree
Given the root of a binary tree where each node contains an integer value (which may be negative), return the maximum possible sum of values along any...
Find k-th largest element in array
You are given an unsorted array of integers nums and a positive integer k. Design an efficient algorithm to find the k-th largest element in the array...
Find first and last index of target
You are given an integer array nums sorted in non-decreasing order and an integer target. Return a pair [left, right] where: - left is the index of th...
Maximize min+max of contiguous subarray
You are given an array of n positive integers nums. Find a contiguous subarray that contains at least two elements and maximizes the value: > (minimum...
Find start indices of anagram substrings
You are given two strings: - s: the text string - p: the pattern string Return a list of all starting indices i such that the substring s[i : i + len(...
Compute maximum path sum in a binary tree
You are given the root of a binary tree where each node contains an integer value (which may be positive, zero, or negative). A path in the tree is de...