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,976–4,000
Count the number of distinct non-empty subsequences of a binary string (length up to 1e5) that do not have leading zeros except for the single…
General practice
For each teacher, compute how many distinct subjects they teach across all departments — i.e., group by teacher_id and count the unique subject_id values. Return…
General practice
Given a permutation of 1..n, count how many distinct values can be formed as nums[i] XOR nums[j] XOR nums[k] with i <= j <= k…
General practice
Count the number of distinct values obtainable as nums[i] XOR nums[j] XOR nums[k] over all triplets with i <= j <= k. With n up…
General practice
Given a "hh:mm" string with some digits replaced by '?', count how many valid times can be formed by substituting each '?' with 0–9 under…
General practice
Count the number of ways to choose a destination square for each of n chess pieces (rooks, bishops, queens) on an 8×8 board so that…
General practice
Count the number of contiguous subarrays that satisfy a local ordering constraint (e.g., the first element remains the min/max over the subarray). The core challenge…
General practice
For each 7-letter puzzle, count how many words consist only of letters from that puzzle and also include the puzzle's first letter. Key observation: encode…
General practice
Count how many space-separated tokens in a sentence are "valid words" under the rules that they contain only lowercase letters, at most one hyphen (which…
General practice
For each person in an array of distinct heights, compute how many people to their right are "visible" (j is visible from i if every…
General practice
Count the number of ways to make k-1 axis-aligned cuts on a rows×cols grid of 'A' (apple) and '.' so that each of the k…
General practice
Count how many distinct routes achieve the minimum travel time from node 0 to node n-1 in a connected undirected weighted graph. The standard approach…
General practice
Compute the maximum depth (number of edges) from root 1 to any deepest node in the tree, then count assignments of weights {1,2} on that…
General practice
Count assignments on the simple path between two nodes so that the sum of edge weights (each either 1 or 2) is odd — equivalently…
General practice
Count how many distinct stable "house of cards" structures can be built given a number of cards (or levels) under the problem's per-level construction rules…
General practice
Count how many ways to build an h-row wall of given width by arranging bricks in each row (bricks of integer lengths summing to the…
General practice
Count the number of nonnegative integer pairs (pens, pencils) satisfying cost1*pens + cost2*pencils ≤ total — i.e., count integer solutions to a linear inequality. This…
General practice
Count the ways to insert dividers between characters in a string of 'S' (seats) and 'P' (plants) so every resulting section contains exactly two 'S'…
General practice
Count the number of combinations to reach exactly target points using up to count_i indistinguishable items worth marks_i each (order doesn't matter) — a bounded…
General practice
Count the number of ways to form target left-to-right by picking each target character from some word’s character at column k, with the constraint that…
Companies: Uber
Array · Dynamic Programming · String
Count the number of ways to color an n×3 grid with 3 colors so that no two adjacent cells (horizontally or vertically) share a color…
General practice
Count the number of length-k sequences of ±1 moves on an infinite number line that take you from startPos to endPos — equivalently, choose how…
General practice
Count the number of distinct ways to go from the top-left to the bottom-right of a grid under given movement constraints (e.g., obstacles or variable…
General practice
Count how many permutations of 1..n have exactly k left-to-right visible sticks (records) — a combinatorics/DP counting problem where placing the largest stick either creates…
General practice