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,001–4,025
Given unordered pairs that specify exactly which node pairs are in an ancestor-descendant relationship (a pair exists iff one node is an ancestor of the…
General practice
Count how many permutations of the given array produce the identical BST when inserted in order — the core challenge is a recursive combinatorics problem…
General practice
Count the number of index triples i<j<k in a binary string that form an alternating pattern "010" or "101" (so no two consecutive selected buildings…
General practice
Count the number of ways to split the digit string into a sequence of positive integers (no leading zeros) that is non-decreasing, returning the count…
General practice
Count the ways to split a binary string into three non-empty substrings that each contain the same number of '1's. The solution hinges on whether…
General practice
Count the number of split indices i (0 ≤ i < n-1) such that the prefix sum up to i is at least the suffix…
General practice
Count the number of sequences of left/right/stay moves on a 1D array of length arrLen starting at index 0 that return to index 0 after…
General practice
Count the number of ways to assign distinct hats (labels 1..40) to n ≤ 10 people given each person's allowed hat list, returning the answer…
Companies: Roblox
Array · Bipartite Graph · Bit Manipulation · Bitmask
Count the number of triplets across two arrays where the square of one element equals the product of two distinct elements from the other array…
General practice
Count the number of non-empty substrings (in a string of letters 'a'–'j') whose character counts have at most one odd frequency. Core idea: track a…
Companies: Uber
Bit Manipulation · Hash Table · Prefix Sum · String
Count the total number of contiguous subarrays made entirely of zeros by scanning for maximal runs of consecutive zeros and summing the number of subarrays…
General practice
Companies: Amazon, Bloomberg, Google, Meta +1
Dynamic Programming · Prefix Sum
Companies: Amazon, Bloomberg, Google
Dynamic Programming · Math
Count how many positive integers you can form (with unlimited repeats from a given set of allowed digits) that are <= n. This is solved…
General practice
Count how many positive integers ≤ n contain at least one repeated digit. Solve by complementary counting / digit-DP: compute how many numbers ≤ n…
General practice
Generate all n-digit integers (no leading zeros) whose adjacent digits have absolute difference k — a digit-by-digit construction problem solvable by DFS/BFS from starting…
General practice
Given a space-separated text and two words first and second, find every word that immediately follows the bigram "first second" — i.e., split the text…
General practice
Group transactions by date and use conditional aggregation to compute odd_sum (sum of amounts where transaction_id is odd) and even_sum (sum where it's even), showing…
General practice
Given an array of equal-length lowercase strings, compute each string's adjacent-letter difference array (alphabet index deltas) and return the single string whose difference…
General practice
Given an array where every number appears twice except for two distinct numbers that appear only once, find those two unique numbers. The core challenge…
General practice
Determine whether two strings are exactly one edit apart — i.e., one insertion, deletion, or replacement turns one into the other. Solve in linear time…
General practice
Select the largest subset of binary strings from strs such that the total number of 0's is ≤ m and total number of 1's is…
General practice