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 2,126–2,150
Count the number of distinct subsequences of s that equal t — i.e., the number of ways to delete characters from s (keeping relative order)…
Companies: Swiggy
Dynamic Programming · String
Count the number of distinct non-empty subsequences of a string modulo 1e9+7. This is typically solved with dynamic programming that doubles the count for each…
General practice
Given an even-length array of candy types and a limit of n/2 candies to eat, maximize the number of different types Alice can consume. Count…
General practice
Count the number of nonnegative integer triples (a, b, c) that sum to n with each value ≤ limit. This is a constrained stars-and-bars counting…
General practice
Count the number of nonnegative integer triples (a,b,c) with a + b + c = n and 0 ≤ a,b,c ≤ limit. With n, limit…
General practice
Partition an array of candy values among k children to achieve a fairness objective (e.g., make each child's total equal or maximize the number of…
General practice
Distribute candies in an increasing sequence (1,2,3,...) cyclically among num_people and return each person's final total — compute how many full rounds and the final…
General practice
Given a binary tree where total coins equals the number of nodes, compute the minimum number of parent-child moves needed so every node has exactly…
General practice
Simulate a greedy sequential distribution: put nums[0] in arr1 and nums[1] in arr2, then for each subsequent nums[i] append it to arr1 if the last…
General practice
Process nums left-to-right to build arr1 and arr2: for each nums[i], append it to the array that currently has fewer elements strictly greater than nums[i]…
General practice
Given a total amount and number of children, allocate all money so each child gets at least $1 and nobody gets $4, and return the…
Companies: MongoDB
Greedy · Math
Given nums (with at most 50 distinct values) and up to 10 customers each requiring quantity[i] identical items, determine whether you can assign to every…
General practice
Partition the string s into consecutive groups of size k and return those substrings, padding the final group with the given fill character as many…
General practice
Partition the array into three contiguous parts by choosing two cut indices; the cost is the sum of the first elements of each part (nums[0]…
General practice
Partition nums into k contiguous subarrays (with starts s0=0<s1<...<s_{k-1}) to minimize the sum of each subarray's first element, subject to the constraint s_{k-1}-s1 ≤ dist…
General practice
Partition the array (n is a multiple of 3) into n/3 triplets such that within every triplet the max minus min ≤ k, returning any…
General practice
Given an array of 2n integers, determine whether its elements can be partitioned into n pairs where both elements in each pair are equal. This…
General practice
Partition the array's elements into disjoint strictly increasing sequences that together use every element (or decide the minimum number of such sequences / whether a…
General practice
Given an array of sweetness values for sequential chocolate chunks, partition it into k+1 contiguous pieces so as to maximize the minimum total sweetness among…
General practice
Partition the given intervals into the minimum number of groups so that no two intervals in a group overlap. This is equivalent to finding the…
General practice
Assign each node an integer group 1..m so every edge joins nodes whose group indices differ by exactly 1; return the maximum possible m or…
General practice
Given an even-length array of player skills, pair players into n/2 teams so every pair has the same total skill; return the sum of the…
General practice
Divide two 32-bit signed integers without using multiplication, division, or modulo, returning the quotient truncated toward zero. Handle divisor != 0 and clamp to 32-bit…
General practice
Compute the difference between the sum of integers in [1, n] not divisible by m and the sum of those that are; use arithmetic series/count…
General practice