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,151–3,175
Choose one drink per hour to maximize total energy over n hours, where drinking A or B yields the given hourly rewards but switching drinks…
General practice
Companies: Amazon
Array · Counting · Hash Table
Find the longest prefix of an array such that by removing exactly one element from that prefix, all remaining distinct values have the same occurrence…
General practice
Find the maximum sum of any contiguous subarray that contains only unique elements. This reduces to a sliding-window / two-pointer problem maintaining a seen-set and…
General practice
Given a screen width and height, a sentence (words separated by spaces), and a font-size-dependent character width/line height model, find the largest integer font size…
General practice
Choose one contiguous subarray and add the same integer x to every element once to maximize how many elements equal k afterward. Algorithmically, this is…
General practice
Given nums, k, and numOperations, you may pick up to numOperations distinct indices and add an integer in [-k, k] to each; find the maximum…
General practice
You can perform up to numOperations pointwise edits (each adding a value in [-k,k]) on distinct indices to make as many array entries equal as…
General practice
Given an integer array, find the contiguous subarray that maximizes a score defined by element frequencies (a function of each element's count within the subarray)…
General practice
Given sorted fruit positions with amounts, find the maximum total fruits collectible starting at startPos with at most k steps, where you may walk left…
General practice
Given an integer array, find the maximum difference between successive elements in its sorted order; if fewer than two elements return 0. The catch is…
Companies: Waymo
Array · Bucket Sort · Pigeonhole Principle · Radix Sort
Companies: Amazon
Greedy · String · Two Pointers
Given an array of positive integers, find a contiguous subarray that maximizes the total GCD-score defined by summing gcd(a[i], a[j]) over all unordered pairs of…
General practice
Given a rooted tree where each node's value equals its index, answer queries asking for the maximum XOR between a given value and any node…
General practice
Given an n×n matrix of statements where "good" people always tell the truth and "bad" people can lie, find the largest set of people that…
General practice
For each node in a rooted tree, find the maximum sum of a subset of nodes in its subtree such that across the chosen nodes…
General practice
Given an array, find the maximum Hamming distance between the array and any of its cyclic rotations — i.e., the largest number of indices i…
General practice
Find the largest height h such that rows 1..h (row i has i balls) can be colored alternately with one color per row without exceeding…
General practice
Given a list of ice-cream prices and a budget, maximize the number of bars you can buy by greedily taking the cheapest items first. Because…
General practice
Given an integer array, find indices i < j < k with nums[i] < nums[j] < nums[k] that maximize the sum nums[i] + nums[j] +…
General practice
Find the largest non-negative integer k such that the permutation nums can be sorted by swapping only pairs of elements whose bitwise AND equals k…
General practice
Given pairs [left, right] with left < right, find the maximum number of pairs you can select so that each chosen pair's left is strictly…
General practice
Find the maximum length of a contiguous subarray that appears in both input arrays (the longest common substring problem for arrays); constraints (lengths ≤1000, values…
General practice
Given an integer array, return the maximum length of a contiguous subarray that satisfies the problem's "semi-decreasing" property (a relaxed/non-strictly-decreasing condition…
General practice
Find the longest contiguous subarray whose product is positive. The array can be split by zeros into independent segments, and within each segment the parity…
General practice