The Profitable Schemes problem gives you a list of criminal schemes, each requiring some members and generating some profit. Find how many subsets of schemes generate at least minProfit using at most n gang members. Return the count modulo 10^9+7. This hard coding problem is a 2D knapsack: limited capacity (members) and minimum requirement (profit). The array and dynamic programming interview pattern is fully tested.
Amazon and Google ask this because it extends the standard 0/1 knapsack to two constraints: capacity (members ≤ n) and floor constraint (profit ≥ minProfit). The "at least" constraint for profit requires careful DP state design.
2D DP (members, profit). dp[j][p] = number of schemes using exactly j members with exactly p profit (or profit capped at minProfit). For each scheme (members, profit): update DP in reverse: dp[j][p] += dp[j-members][max(0,p-profit)]. Answer = sum of dp[j][minProfit] for j=0..n. The profit dimension is capped at minProfit (any profit above minimum counts the same).
n=5, minProfit=3, group=[2,2], profit=[2,3].
min(p, minProfit).Profitable Schemes is 2D 0/1 knapsack with a floor constraint. The key insight: cap the profit dimension at minProfit because any profit above the minimum is treated the same (we only care about reaching the threshold, not exceeding it). Practice: "0/1 knapsack with budget and minimum profit," "task scheduling with two resources," "item selection with two constraints." The profit-capping technique generalizes to any "at least k" DP constraint.