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,251–3,275
Given three integers, permute and concatenate their binary representations (without leading zeros) to form the largest possible binary number and return its integer value. The…
General practice
Given item types each with a weight and a price, determine the maximum total price you can achieve by choosing nonnegative quantities of the types…
General practice
Find the maximum index distance between any two prime numbers in the array — equivalently the gap between the first and last prime occurrences —…
General practice
Distribute up to k unit increments among the array elements to maximize their product — a greedy "level up the smallest elements" allocation (use sorting…
General practice
Given an array nums, choose four distinct elements to maximize the product difference (a*b - c*d). The core challenge is recognizing that the optimal choice…
General practice
Choose a subsequence of length m that maximizes the product of its first and last elements — equivalently, pick indices i ≤ j with j…
General practice
Find an edge whose removal splits the tree into two subtrees such that the product of their sums is maximized, and return that maximum product…
General practice
Find a non-empty subsequence (order preserved) whose alternating sum (+,-,+,...) equals k and whose product is maximized but does not exceed limit. The core challenge…
General practice
Find two disjoint palindromic subsequences of a short string (n ≤ 12) such that the product of their lengths is maximized. Because n is small…
General practice
Find two non-overlapping odd-length palindromic substrings in s that maximize the product of their lengths. The core challenge is to efficiently enumerate all odd palindromes…
General practice
Companies: Google, Meta
Array · Greedy · Math · Sorting
Given a positive integer n, return the maximum product obtainable by multiplying any two of its digits (a digit can be used twice if it…
General practice
Given an integer array, pick two distinct indices to maximize (nums[i]-1)*(nums[j]-1). This is equivalent to selecting the two largest elements and returning (max1-1)*(max2-1).
General practice
Find two distinct elements in nums (n up to 1e5, values ≤1e6) whose binary representations share no set bits (nums[i] & nums[j] == 0) and…
General practice
Given an array of lowercase words, find the maximum product of lengths of two words that share no common letters. The challenge is efficiently checking…
General practice
Given a rooted company tree with buy/sell prices for each employee, pick a subset of nodes to buy (each at most once) under a total…
General practice
Given a DAG with node scores, find a topological ordering that maximizes the sum of score[i] * position(i) (positions are 1-based) while respecting all edge…
General practice
Simulate the wheel: process arrivals and greedily board up to 4 waiting customers each rotation while tracking cumulative profit = boarded*boardingCost − rotations*runningCost…
General practice
Given an array of prices, choose indices i < j < k with strictly increasing prices[i] < prices[j] < prices[k] to maximize the total profit…
General practice
Given an array of prices, choose non-overlapping triplets of indices (i<j<k) whose prices are strictly increasing to maximize the total profit across chosen triplets; the…
General practice
Given strings sequence and word, find the largest integer k such that word repeated k times (word^k) appears as a contiguous substring of sequence, returning…
General practice
Given an m×n binary matrix and an integer numSelect, choose exactly numSelect columns to maximize the number of rows whose 1s are all contained within…
General practice