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 4,176–4,200
Given equal-length digit strings, each query (k, trim) asks you to truncate every number to its rightmost trim digits and return the index of the…
General practice
Each answer x implies a color group of size x+1; the task is to aggregate identical answers and, for each x, take the minimum number…
General practice
Find the minimum-length sequence of instructions (A: position+=speed, speed*=2; R: reverse to ±1) to move a car from 0 with initial speed +1 to a…
General practice
Implement a class that repeatedly returns and flips a uniformly random unpicked cell (i, j) from an m×n zero-initialized binary matrix and can reset the…
General practice
Given non-overlapping axis-aligned rectangles, pick a uniformly random integer point from their union by treating each rectangle's count of integer lattice points as its…
General practice
Given an initial zero array and a list of range update operations [start, end, inc], apply all increments and return the final array; the challenge…
General practice
Given an m x n zero matrix and ops that each increment every cell in the top-left submatrix [0, ai) x [0, bi), return how…
General practice
Preprocess the array to support fast count queries that return how many times a given value appears in arr[left..right]; a common approach stores each value's…
General practice
Decompose n into the minimal sorted list of powers of two that sum to it (equivalently the powers corresponding to its set bits). For each…
General practice
Compute the sum of the subarray sums that rank between left and right (1-indexed) after sorting all O(n^2) non-empty subarray sums of a positive-integer array…
General practice
Support efficient point updates and range-sum queries on an integer array: update index to a new value and return the sum of nums[left..right]. With up…
General practice
Given an immutable m×n matrix, design a data structure to return the sum of any sub-rectangle [row1..row2]×[col1..col2] in O(1) time; the core challenge is to…
General practice
Maintain an array under two online operations — reverse any subarray and query the XOR of a given range — with up to many operations…
General practice
Given a table of floating-point game scores, assign a dense rank to each score sorted from highest to lowest so tied scores share the same…
General practice
Sort teams by aggregating position-wise vote counts: compare teams by their counts for first place, then second place, and so on, using alphabetical order as…
Companies: Atlassian
Array · Counting · Hash Table · Sorting
Assign the smallest possible positive integer rank to each matrix cell so that ranks in any row or column preserve the ordering of values (equal…
General practice
Replace each number by its rank among the distinct values (smallest value → rank 1, equal values share the same rank), effectively performing a coordinate-compression…
General practice
Find the minimum k such that by taking moves of lengths 1..k (each either left or right) you can land at target; this reduces to…
General practice
Given an array nums, start at index 0 and jump only forward to reach n-1, where a jump i→j yields score (j−i)*nums[i]; maximize the total…
General practice
Count how many nodes (both original and the cnt intermediate nodes that subdivide each edge) are reachable from node 0 within maxMoves in an implicitly…
General practice
Given an undirected tree and a set of restricted (blocked) nodes, count how many nodes are reachable from node 0 without visiting any restricted node…
General practice
Given start (sx, sy) and target (tx, ty) where each move adds one coordinate to the other, determine if the target can be reached from…
General practice
Implement a read(n) method using the provided read4(buf) API where read may be called multiple times; you must preserve and reuse leftover characters between calls…
Companies: Lyft, NVIDIA
Array · Interactive · Simulation