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,951–1,975
Given an undirected graph, count the number of unordered node pairs that are unreachable from each other — equivalently, pairs that lie in different connected…
General practice
Count the number of unordered node pairs (a, b) in a tree whose simple path contains exactly one prime-labeled node. With n up to 1e5…
General practice
Given a functional directed graph (each node has exactly one outgoing edge), compute for every node how many distinct nodes are visited when repeatedly following…
General practice
Given an array of words and many range queries, count how many strings in each query range start and end with a vowel; preprocess by…
General practice
Count the number of contiguous substrings that consist only of vowels and contain all five vowels (a, e, i, o, u) at least once. The…
Companies: D. E. Shaw, Expedia, Salesforce, Snowflake
Hash Table · String
Count the number of length-n vowel strings that correspond to walks of length n−1 in a fixed directed graph of 5 states given by the…
General practice
You can repeatedly append either a block of '0' characters of length zero or a block of '1' characters of length one; count how many…
General practice
Given a rooted tree (parent array) where you can build a room only after its parent and you can move only along already-built edges, count…
General practice
Count the number of distinct ways to distribute candies to recipients under given constraints (such as limits per type or per child, and indistinguishable vs…
General practice
Given a list of intervals, count how many ways to assign each interval to one of two groups so that any overlapping intervals are in…
General practice
For each query (n, k), count n-length positive integer arrays whose product is k by prime-factorizing k and using stars-and-bars to distribute each prime's exponents…
General practice
Count how many target words can be obtained by taking some start word, appending exactly one new letter not already present, and permuting the result…
General practice
Given n servers and timestamped request logs, for each query time return how many servers received no requests in the inclusive interval [query - x…
General practice
Return a function (closure) that captures an initial integer n and, on each invocation, returns n for the first call and increments by 1 on…
General practice
Implement a factory function createCounter(init) that captures an initial integer and returns three methods—increment, decrement, and reset—that update and return the internal…
General practice