Interview questions
Find a company or topic. Read the sources, then practice.
Loading the question library…
Find a company or topic. Read the sources, then practice.
Loading the question library…
Showing 3,501–3,525
Given n piles where you can repeatedly merge exactly k consecutive piles at cost equal to their sum, compute the minimum total cost to merge…
General practice
Companies: Visa
Array · Greedy · Prefix Sum
Chips can move by ±2 for free but ±1 costs 1, so the problem asks for the minimum cost to gather all chips at one…
General practice
Companies: Amazon
Divide and Conquer · Prefix Sum · String
Find the minimum travel cost from a source city to a destination in a weighted graph when you may apply a limited number of discounts…
General practice
Find a path from city 0 to city n-1 in an undirected graph where edges have travel times and each node has a passing fee…
General practice
Starting from position n you can reach any target i by paying some person j ≤ i to swap once (cost[j]) and then moving through…
General practice
Given a sequence of words and a maximum line width, partition the words (in order) into rows to minimize the total penalty where each row…
General practice
Split the array into contiguous subarrays to minimize the total cost where each segment costs k plus the number of elements in that segment that…
General practice
Given an array of positive integers as the in-order leaves of a full binary tree, choose the tree shape that minimizes the sum of internal-node…
General practice
For each query, find the smallest possible bitwise AND of edge weights along any walk (edges/vertices may repeat) between two nodes in an undirected weighted…
General practice
Compute the minimum number of straight cuts through the circle's center (diameters or radius-through-center lines) needed to split the circle into n equal congruent slices…
General practice
Given an undirected graph, find all connected trios (triangles) and compute each trio's degree — the number of edges with one endpoint in the trio…
General practice
Given a lowercase string s and integer k, delete the fewest characters so the resulting string contains at most k distinct letters. The optimal approach…
General practice
Delete the fewest elements so the remaining array has even length and every consecutive pair (indices 0&1, 2&3, ...) contains two different values. The core…
General practice
Delete as few elements from nums as needed so that the smallest remaining element divides every number in numsDivide, returning -1 if impossible. Key observation…
General practice