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 2,801–2,825
Given distinct positive integers, return the largest subset in which for every pair of elements one divides the other. This reduces to finding the longest…
General practice
Given a positive integer array where you may repeatedly merge an adjacent pair (i,i+1) only if nums[i] <= nums[i+1] by replacing nums[i+1] with their sum…
General practice
Generate an (n-2) x (n-2) matrix where each entry is the maximum value in the corresponding contiguous 3x3 submatrix of the input n x n…
General practice
Find the largest side length k of any k×k subgrid whose every row sum, every column sum, and both diagonal sums are equal (entries need…
General practice
Given two strings, build the lexicographically largest merge by repeatedly taking the first character of either string; the core challenge is a greedy decision at…
General practice
Select a subset of the given digits and arrange them to form the largest possible number divisible by three (or return an empty string if…
General practice
Arrange the numbers to form the largest possible concatenated value by treating them as strings and ordering them with a custom comparator that places a…
General practice
Given an integer, you may swap any two digits that share parity (both even or both odd); compute the maximum possible integer obtainable by permuting…
General practice
Given a numeric string and a mapping for each digit, choose at most one contiguous substring to replace each digit by its mapped value so…
General practice
Given an integer array with a unique maximum, determine whether the largest element is at least twice every other element and return its index if…
General practice
Given a numeric string, return the largest-valued odd integer substring (or "" if none). The solution is to find the rightmost odd digit—because the numerically…
General practice
Given n (1 ≤ n ≤ 8), find the largest palindromic integer that can be expressed as the product of two n-digit numbers and return…
General practice
Given a string of digits, form the largest numeric palindrome (no leading zeros, must use at least one digit) by selecting and reordering digits from…
General practice
Given an array of side lengths, pick three lengths that satisfy the triangle inequality (sum of any two sides > the third) to form a…
General practice
Find the largest positive integer k such that both k and -k occur in the given nonzero integer array; return that k or -1 if…
General practice
Companies: Google, Meta
Array · Math · Number Theory
Find the maximum area of a rectangle formed by contiguous bars in a histogram (given bar heights). The core challenge is determining each bar's maximal…
Companies: Bloomberg, Microsoft
Array · Monotonic Stack · Range Minimum/Maximum Query · Stack
Given a binary m x n matrix whose columns can be permuted arbitrarily, find the maximum area of an all-ones submatrix achievable after optimal column…
General practice
Given a string s, compute the maximum number of characters strictly between any two equal characters (i.e., maximize j - i - 1 for s[i]…
General practice
Partition the array into at most k contiguous non-empty subarrays (using all elements) to maximize the sum of each subarray's average. This is an optimization…
General practice
Given four digits, arrange each exactly once to form a valid 24-hour time "HH:MM" (HH between 00–23, MM between 00–59) and return the latest possible…
General practice
Given up to 50 distinct 2D points, find the maximum area of any triangle formed by three of them; compute triangle area (e.g., via cross…
General practice