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,776–2,800
Find the k-th smallest integer in lexicographic order among [1, n]. Because n can be large (up to 10^9), the challenge is to traverse the…
General practice
Given a sorted array of unique primes (starting with 1), find the k-th smallest fraction arr[i]/arr[j] (with i<j) among all pairs; the challenge is to…
General practice
Given a binary sequence that evolves each row by replacing 0→01 and 1→10 (so row lengths double each time), return the k-th symbol in the…
Companies: D. E. Shaw
Bit Manipulation · Math · Recursion
Repeatedly double the given integer while its current value exists in the array, and return the first value that is not found. The core challenge…
General practice
Given rooms as an adjacency list where keys in room i are directed edges to other rooms, determine whether all nodes are reachable starting from…
General practice
For each child, determine whether giving them all extraCandies makes their total at least the current maximum candies among all kids — equivalently, compare candies[i]…
General practice
Given lists of process IDs and their parent IDs plus a target PID to kill, return that PID and all its descendant PIDs in the…
General practice
Count how many length-n phone numbers can be formed by starting on any digit of the phone keypad and making n-1 valid knight moves: equivalently…
General practice
Given an n×n board and a starting cell, compute the probability a knight that chooses each of its eight moves uniformly at random stays on…
General practice
Given a rooted tree as a parent[] array, preprocess it to efficiently answer many queries asking for the k-th ancestor of a node (return -1…
General practice
Return the k-th string in the array that appears exactly once (a "distinct" string) in the original order, or "" if fewer than k distinct…
General practice
Compute the sum of node values at each tree level (via BFS/level-order traversal) and return the k-th largest level sum (or -1 if there are…
General practice
Given coin denominations where you may only use multiples of a single denomination, find the k-th smallest distinct amount in the union of those arithmetic…
General practice
Given counts of right moves (H) and down moves (V), return the k-th lexicographically smallest length-(row+column) string with those counts that reaches (row,column). The core…
General practice
Find the k-th smallest value in an m x n multiplication table (mat[i][j] = i*j) without building the table. This is solved by binary-searching the…
General practice
Compute each node's root-to-node XOR, and for each query return the k-th smallest distinct XOR value among all nodes in a given subtree (or -1…
General practice
Given two sorted integer arrays, find the k-th smallest value among all pairwise products nums1[i]*nums2[j] without materializing all pairs; the core challenge is to…
General practice
Given an array of positive integers, find the k-th smallest sum among all contiguous subarray sums. Because elements are positive, you can binary-search the target…
General practice
Given a binary matrix, return the area of the largest square subgrid whose four borders are entirely 1s (interior may be 0), or 0 if…
General practice
Given a numeric string, return the largest "good" integer — a length-3 substring made of the same repeated digit (leading zeros allowed) — or ""…
General practice
Given a binary tree, find the size (number of nodes) of the largest subtree that is a valid binary search tree. The challenge is to…
General practice
Given a directed graph where each node has a lowercase color, find the maximum number of occurrences of any single color along any valid path…
General practice
Find the size of the largest subset of integers whose bitwise AND is > 0 — equivalently, determine the maximum number of elements that share…
General practice
Given unique positive integers, build a graph connecting numbers that share a common factor >1 and return the size of the largest connected component —…
General practice