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,001–3,025
Given a 3x3 grid of 'B' and 'W', determine whether flipping at most one cell can produce a 2x2 sub-square with all four cells the…
General practice
Count how many choices of a starting index at a zero and an initial left/right direction yield a deterministic walk—where stepping on a positive decrements…
General practice
Given a distinct integer array, repeatedly either remove the first element if it is the current minimum or move it to the end, and return…
General practice
Partition the array into contiguous segments (each can be replaced by its maximum) and choose the partition that maximizes the number of segments such that…
General practice
Given an integer array, determine the minimum work (removals/changes/operations as defined) required to make the array monotonic either non-decreasing or non-increasing; the…
General practice
Given arr1 and arr2, find the minimum number of replacements (each replacement sets arr1[i] to any value from arr2) required to make arr1 strictly increasing…
General practice
Given a non-negative integer array, repeatedly subtract a positive x (≤ the current smallest non-zero element) from all positive entries and return the minimum operations…
General practice
Given a perfect binary tree with costs on each node and the ability to increment any node's cost by 1, find the minimum number of…
General practice
Given a circular array and integer k, find the minimum number of ±1 element operations to make every length-k subarray sum equal; this reduces to…
General practice
You may swap two indices iff their values differ by at most limit; compute the lexicographically smallest array obtainable by any sequence of such swaps…
Companies: Goldman Sachs, Uber
Array · Sorting · Union-Find
Determine whether a single swap of one character from each of two lowercase strings can make their counts of distinct characters equal. The core challenge…
General practice
Return an immutable version of a given object so that any attempts to add, delete, or modify properties fail or are blocked. The challenge is…
General practice
Given a string, transform it into an anti-palindrome (s[i] != s[n-1-i] for all i) using the minimum number of character replacements (or report impossibility). Key…
General practice
Find the shortest non-empty (or possibly empty) contiguous subarray to remove (but not the entire array) so that the remaining elements' sum is divisible by…
General practice
Given an integer array, determine the minimum modifications needed so that every prefix sum is non-negative — a problem about controlling running sums by selectively…
General practice
Repeatedly remove adjacent pairs of the same letter in opposite cases (e.g., 'a' and 'A') until no such pairs remain, and return the resulting unique…
General practice
Given an array nums and integer k, find the minimum number of element changes so that every contiguous subarray of length k has XOR equal…
General practice
Find the minimum number of right-end deletions (you may not empty a string) required to make three strings identical — equivalently compute the longest non-empty…
General practice
Determine whether you can transform arr into target by reversing any non-empty subarrays any number of times — equivalently, check if target and arr contain…
General practice
Given an employees table with manager relationships, find the manager who oversees the largest department (most direct reports) and return their id and name; if…
General practice
Identify employees who are managers of at least five direct reports by grouping rows by managerId, filtering groups with count >= 5, and returning the…
General practice
Compute the total sum of pairwise Manhattan distances over all ways to place k identical pieces on an m×n grid (one per cell), modulo 1e9+7…
General practice
Assign nonnegative heights to a grid so water cells are 0, adjacent cells differ by at most 1, and the global maximum height is maximized…
General practice
Support insert(key, val) (overwriting existing keys) and sum(prefix) that returns the total of values for all keys starting with that prefix. The core challenge is…
General practice
Given nums and queries where each query marks a specified index (if not already) and then marks up to k currently-unmarked elements with the smallest…
General practice