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,851–3,875
Given the root of an N-ary tree, produce its preorder traversal (visit each node before its children, left-to-right) as a list of values. Constraints: up…
General practice
Count the number of distinct ways to place n queens on an n×n chessboard so that no two attack each other; solve by exploring valid…
General practice
Given an array of length 2n containing n+1 distinct values where exactly one value appears n times, return the value that is repeated n times…
General practice
Return the nth Tribonacci number defined by T0=0, T1=1, T2=1 and Tn = Tn-1 + Tn-2 + Tn-3 for n>=3; with 0<=n<=37 the result fits…
General practice
Count the number of ordered pairs of distinct words (A, B) from a list such that swapping their first letters produces two new words that…
General practice
Given a circular binary array original, derived[i] = original[i] ⊕ original[(i+1) mod n]; determine if there exists a binary original that produces the given derived…
General practice
Given an array of distinct positive integers, return any element that is neither the global minimum nor the global maximum, or -1 if no such…
General practice
Given a recursively nested array of integers, implement a generator that lazily yields integers in left-to-right (depth‑first) order without building a flattened copy, handling…
General practice
Given a directed acyclic graph with weighted edges and some offline nodes, find a path from 0 to n−1 whose intermediate nodes are all online…
General practice
Compute the probability that Alice’s final total is ≤ n when she draws i.i.d. uniform integers from [1, maxPts] until her score reaches at least…
General practice
Given a table of user activity/dates, determine how many users are "new" each day by identifying each user's earliest activity date and aggregating counts per…
General practice
Given a time in 24-hour "HH:MM" format, find the next strictly later time (allowing wrap to the next day) that can be formed using only…
General practice
Given a calendar date (e.g., year, month, day or a "YYYY-MM-DD" string), compute the next day's date by advancing the day while correctly handling month…
General practice
Find the smallest integer > n such that for every digit d in the number, digit d appears exactly d times. The core challenge is…
General practice
Find the smallest integer > n that is a palindrome and whose digit multiset satisfies "each digit k appears either 0 or exactly k times."…
General practice
Determine whether the first player can force a win in a two-player game where players alternately remove 1–3 stones from a heap under optimal play…
General practice
Determine whether an integer array can be made non-decreasing by modifying at most one element. The core challenge is a greedy single-pass: detect inversions (nums[i]…
General practice
Count how many integers in [0, n] have binary representations that never contain consecutive 1s; this is typically solved by scanning n's bits and using…
General practice
Companies: Meta
Select movies from the Cinema table whose id is odd and whose description is not "boring", and return those rows ordered by rating in descending…
General practice
Given an array of periodic cash flows and a fixed discount rate, answer multiple queries asking for the net present value of a subarray (the…
General practice
Find the nth digit in the infinite concatenation "123456789101112...". The core challenge is to identify which digit-length group (1-, 2-, 3-, …-digit numbers) contains the…
General practice
Find the nth positive integer divisible by a or b (i.e., multiples of a or b). Because n can be up to 1e9, use inclusion–exclusion…
General practice