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,351–2,375
Return any array of n distinct integers that sum to zero — the typical approach is to pair opposite numbers and include 0 if n…
General practice
Given your location (x,y) and a list of points, find the index of a point that shares either the same x or y coordinate and…
General practice
Given a binary tree and a target node, return the node immediately to the right of the target on the same depth (or null if…
General practice
Companies: Google
Bit Manipulation · Combinatorics · Math
For each node in a rooted tree, compute coins = 1 if its subtree has fewer than 3 nodes, otherwise the maximum product of any…
General practice
Count the number of operation sequences starting from stair 1 with jump=0 that can reach stair k, where each step is either down by 1…
General practice
Count how many integers in an array have an even number of digits. Constraints are small (n ≤ 500, nums[i] ≤ 10^5), so a linear…
General practice
For each query k, return the index of the k-th occurrence of x in nums (or -1 if fewer than k occurrences exist). Because nums…
General practice
Given an array "changed" that was formed by taking some unknown "original", appending twice each element, and shuffling, return any valid original array or []…
General practice
Group meetings by employee and calendar week (Monday–Sunday) and sum duration_hours to find weeks where an employee spent >20 meeting hours (>50% of a 40‑hour…
General practice
Given multiple employees’ shift intervals, compute all time spans where shifts overlap (and optionally which employees or how many) — a hard variant that requires…
General practice
For each query k, return the k-th smallest positive palindrome with exactly intLength digits (no leading zeros), or -1 if fewer than k palindromes exist…
General practice
Given a fixed pattern and an infinite character stream arriving one character at a time, determine online whether the pattern has just appeared as a…
General practice
Given an unbounded stream of characters, design an online algorithm that processes each incoming character and reports whether a given pattern has just appeared as…
General practice
Aggregate call records by city and hour to count frequencies and return, for each city, the hour or hours with the maximum number of calls…
General practice
Given a string of 'I' and 'D' of length n-1 that specifies whether each adjacent pair in a permutation of 1..n should be increasing or…
General practice
Given a list of match pairs (winner, loser), compute each player's loss count and return two sorted lists: players who played and have zero losses…
Companies: Palantir
Select a subset of at least three numbers from nums whose largest element is strictly less than the sum of the other chosen elements (polygon…
General practice
Given a black-box function f(x, y) that is strictly increasing in both x and y and a target z, return all positive integer pairs (x…
General practice
Find all distinct product pairs (product1_id < product2_id) that have been co-purchased by the same users, count how many distinct customers bought both, and return…
General practice
Define big_nums by concatenating, for each positive integer in order, the sorted list of powers of two that sum to it (its binary decomposition); big_nums…
General practice
Given a list of product IDs (integers), return the IDs whose decimal representation contains any length‑3 substring of consecutive increasing digits (e.g., "123" or "456")…
General practice
Find all products whose description contains a substring matching the serial-number pattern "SN" followed by exactly four digits, a hyphen, and exactly four more digits…
General practice
Repeatedly remove any word that is an anagram of its immediate predecessor until no adjacent anagrams remain, and return the final array. Algorithmically, this collapses…
General practice
Given intervals with unique start points, return for each interval the index of the interval whose start is the smallest value >= that interval's end…
General practice