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,476–3,500
Given candy prices and a "buy two get one free" rule where the free candy must be no more expensive than the cheaper purchased candy…
General practice
Given a grid with movement costs, find the minimum total cost to go from a start to a target cell while your moves must alternate…
General practice
Find the minimum total cost to reach (m-1,n-1) on an m×n grid where you alternate between moving (only right or down on odd-numbered seconds) —…
General practice
Companies: Meta
Array · Graph Theory · Heap (Priority Queue) · Matrix
Companies: Amazon
Array · Graph Theory · Heap · Matrix
Find the minimum cost to travel from node 0 to node n-1 in a weighted directed graph where each node can, at most once upon…
General practice
Find the minimum cost to go from the top-left to bottom-right of an m×n grid where right/down moves cost the destination cell value and you…
General practice
Given costs for apple packs (typically of sizes that double: 1, 2, 4, …), find the minimum cost to buy at least a target number…
General practice
Companies: Amazon
Array · Graph Theory · Heap (Priority Queue) · Shortest Path
Given a parenthesized boolean expression evaluated left-to-right (no operator precedence), compute the minimum number of single-character flips (change a literal 0↔1 or an…
General practice
Given a list of stick lengths where merging any two sticks costs the sum of their lengths, compute the minimum total cost to combine all…
General practice
Select edges in a bipartite graph (given by a cost matrix) so every vertex in both groups is connected to at least one opposite vertex…
General practice
Companies: Amazon
Array · Dynamic Programming · String
Given positions where a stick must be cut and with each cut costing the current segment length, find the order of cuts that minimizes total…
General practice
Partition nums into contiguous subarrays to minimize the total sum where each segment [l..r] contributes (prefix_sum_up_to_r + k * segment_index) * (sum of cost[l..r])…
General practice
Determine the minimum cost to make all elements equal by choosing a final target value and an optimal mix of single-element (+1 at cost1) and…
General practice
Companies: Uber
Array · Counting · Greedy · Hash Table
Choose k workers and pay each proportional to quality while meeting their minimum wages; the group's cost equals (sum of selected qualities) * max(wage[i]/quality[i]) among…
Companies: Apple
Array · Greedy · Heap (Priority Queue) · Sorting
Given a binary string s (n ≤ 1e5), you may flip any prefix ending at i (cost i+1) or any suffix starting at i (cost…
General practice
Given arrays nums and per-unit costs, choose a target value t to minimize the total cost sum(cost[i] * |nums[i] - t|); this is a convex…
General practice
Choose a palindromic integer y (< 1e9) to change all elements of nums to, minimizing the total cost sum |nums[i]-y|; this is an L1 minimization…
General practice
Given two equal-length arrays, you can pay k to split arr into contiguous blocks and permute them (one such operation can realize any permutation) and/or…
General practice
Given a grid where each cell points to a neighbor and flipping a cell's arrow costs 1, find the minimum number of flips needed to…
General practice