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 1,651–1,675
For each query value, return the floor (largest value ≤ query) and ceil (smallest value ≥ query) that exist in the given binary search tree…
General practice
Find the two prime numbers within [left, right] whose difference is minimal (break ties by the smaller first number), returning [-1, -1] if fewer than…
General practice
For each query (preferred, minSize), find the roomId whose size is at least minSize that minimizes abs(id - preferred) (breaking ties by smaller id), or…
General practice
Given an array of up to 40 integers and a target goal, find a subsequence whose sum minimizes the absolute difference to the goal. This…
General practice
Compute the "clumsy factorial" by applying the operations *, /, +, - in a repeating cycle to the integers n down to 1, using standard…
General practice
Companies: NVIDIA
Given a tree where you can collect all coins within distance 2 of your current node and may move along edges, find the minimum number…
General practice
Given an array of costs and a fixed cost x to cyclically shift all types by one, minimize the total expense to buy one of…
General practice
Given a triangular array of colored cells and a fixed painting operation that affects a cell and nearby cells, determine whether (and with how few…
General practice
Find the connected component containing grid[row][col] (4-directionally adjacent cells with the same color) and recolor only its border cells—those on the grid edge or adjacent…
General practice
Find all unique k-sized subsets of distinct numbers from 1–9 that sum to n. The core challenge is a combinatorial search (backtracking/DFS) with pruning since…
General practice
Generate all k-element subsets from the numbers 1..n — a combinatorial generation problem typically solved with backtracking or lexicographic construction. Expect C(n, k)…
General practice
Return each person's first and last name along with their city and state by performing a left join of Person with Address on personId, showing…
Companies: Google, Meta, Microsoft
Database
Recursively traverse the JSON-derived object/array and remove any keys or array elements whose values are falsy, returning the same structure with falsy-valued…
General practice
Companies: Databricks
For each query string, compute the frequency f(s) of its lexicographically smallest character and return how many words have a strictly larger f(w). Because strings…
General practice
Compare two dotted version strings by splitting them into revisions and comparing each revision's integer value (ignoring leading zeros) left-to-right. If one version has fewer…
General practice
Flip every bit in n's binary representation up to its most significant 1 (i.e., ignore leading zeros) and return the resulting integer. Example: 5 (101)…
General practice
Design a data structure that, given a complete binary tree, supports inserting a new node so the tree remains complete and retrieving the root. The…
General practice
Parse two complex numbers given as "a+bi" strings (with possible negative parts), compute their product using complex arithmetic (real and imaginary part formulas), and return…
General practice