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,376–3,400
Find the maximum distance j - i (i < j) such that nums[i] <= nums[j] in the array — i.e., the farthest valid "ramp". With…
General practice
Recognize that the operation can clear any subset of 1-bits in any element, so for each bit position you can make that bit appear in…
General practice
Given an array and a bit-width, for each query (removing the last element each time) find k < 2^maximumBit that maximizes the XOR of all…
General practice
Given an array, pick two (possibly overlapping or empty) subsequences and maximize the XOR of their XOR-sums — equivalently, choose two values from the set…
General practice
Given a tree with integer node values, compute the XOR-sum of nodes for every node's subtree and find two node-disjoint subtrees whose subtree-XOR values produce…
General practice
Given an array of nonnegative integers, find the maximum XOR value of any pair of elements; the core challenge is to exploit bitwise structure (e.g.…
General practice
Given nums (n ≤ 2000) and up to 10^5 queries [l,r], for each query return the maximum "XOR score" among all contiguous subarrays of nums[l..r]…
General practice
For each query [x, m], return the maximum value of x XOR nums[j] over all nums[j] ≤ m (or -1 if no such element). The…
General practice
Compute the mean of an integer array after removing the smallest 5% and largest 5% of elements (i.e., trim n/20 elements from each end) and…
General practice
Given a collection of employee salaries (often stored in a database table), compute the median salary — returning the middle value for odd counts or…
General practice
Given an R×C matrix where each row is sorted in non-decreasing order, find the median (the middle element if the matrix were flattened) without fully…
General practice
Companies: NVIDIA
Companies: Airbnb
Companies: Google
Implement a memoize wrapper that returns a cached version of one of three functions (sum with two ordered integer args, fib, or factorial) so repeated…
General practice
Implement memoize(fn) that returns a memoized version of any-arity function which caches results keyed by argument identity (strict === equality), so repeated calls with the…
General practice
Companies: Snap
Given n small BSTs (each ≤3 nodes) with distinct root values, determine whether you can repeatedly graft one tree into a leaf of another (when…
General practice
You have fixed distances between signs and per-km times on each segment; each merge removes an internal sign and adds its time to the next…
General practice