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,101–4,125
Given a circular array of length 3n, choose exactly n slices to maximize their total such that picking any slice excludes its two neighbors (no…
General practice
Given a string of '*' (plates) and '|' (candles), answer many queries [l,r] by counting plates that lie strictly between at least one candle to…
General practice
Given an array of digits (most significant first) representing a nonnegative integer, increment the number by one and return the resulting digit array, handling carry…
General practice
Given a list of closed integer intervals [start, end], return the number of distinct integer points covered by the union of those intervals. This is…
General practice
Given a number of buckets and limited time allowing repeated test rounds, determine the minimum number of pigs whose alive/dead outcomes across those rounds uniquely…
General practice
Given initial counts of likes/votes for items/users and a sequence of updates and queries, compute for each query the percentage of the population that meets…
General practice
Find all intervals [start, end] of consecutive identical characters in a lowercase string that have length at least 3 (large groups), and return these intervals…
General practice
Given several buckets with fixed capacities and initial water volumes, determine whether (and if required, the minimum number of pours) you can make all buckets…
General practice
Given an undirected graph of c stations whose connectivity is fixed, process queries that either mark a station offline or ask which operational station with…
General practice
Determine whether a given integer n is a power of four (n == 4^x for some integer x). The key is an O(1) check using…
General practice
Compute the sum over all non-empty subsets of nums of (max(subset)^2 * min(subset)) modulo 1e9+7. With n up to 1e5 you must avoid enumerating subsets…
General practice
Determine whether a given 32-bit signed integer is a power of three (i.e., equals 3^x for some integer x). Typical approaches use repeated division, logarithms…
General practice
Companies: Google
Array · Hash Table · Heap (Priority Queue) · Math
Return all distinct values ≤ bound that can be written as x^i + y^j for nonnegative integers i,j; the core challenge is enumerating pairs of…
General practice
Design a data structure that, given a list of words, returns the index of a word with a given prefix and suffix (return the largest…
General practice
Count how many nonnegative integers x satisfy f(x)=k, where f(x) is the number of trailing zeros in x! (i.e., the sum of floor(x/5^i)). Key insight…
General practice
Aggregate each team's points and goal statistics from given match results, then produce the league standings by sorting teams using standard tie-breakers (e.g., points, goal…
General practice
Aggregate match results to compute each team's standings (points, goal difference, goals scored) and produce a sorted league table using multi-criteria tie-breakers (e.g.…
General practice
Compute a league table from a list of match results by aggregating team stats (points, wins, goal difference, goals scored) and sort teams using multi-level…
General practice
Pretty standard coding questions, equivalent to LC medium/hard. I didn't always arrive at the final answer and was still put through to the next round…
Companies: Airbnb
Given an array of integers, return the lexicographically largest permutation that is smaller than the original and can be obtained with exactly one swap (or…
General practice
For each employee, report their primary department by selecting the department_id with primary_flag = 'Y' if one exists; if an employee belongs to only one…
General practice
Count permutations of 1..n where every prime number appears at a prime (1-based) index — equivalently, with p = number of primes ≤ n, compute…
General practice