Skip to main content
All Questions

Count the ordered sequences of order sizes, each taken from a given set of distinct positive integers, that add up to exactly n shares.

Unlock detailed company stats for this questionUpgrade
You want to buy exactly n shares and may place any number of orders in sequence; each order fills an amount equal to one value from a given array of distinct positive integers k. Count the distinct sequences of orders that total n (order matters), returning 0 if impossible. Example: n = 3, k = [1, 2] gives 3 (1+1+1, 1+2, 2+1).

Community answers

No answers contributed by the community yet.

Related courses

Course

SQL Interview Prep Course

Prepare for SQL interviews with lessons on joins, aggregations, and window functions, then practice real SQL interview questions in an interactive editor with expert solutions.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.