Shopping Spree Problem Statement
Preeti plans to shop for her father's birthday at a store with unlimited quantities of N different items. She has a budget that allows her to buy a maximum of K items. Help Preeti determine the number of different ways she can purchase these items, where two ways are considered distinct if at least one item quantity differs.
Input:
The first line of the input contains an integer T, representing the number of test cases.
Each test case consists of a single line with two integers, N and K, indicating the number of item types and the maximum number of items Preeti can buy, respectively.
Output:
For each test case, output a single line with the number of different ways to purchase the items.
Example:
Input:
2
2 2
3 3
Output:
3
10
Constraints:
1 <= T <= 10
1 <= N <= 1000
1 <= K <= 1000
As the answer can be large, return your result modulo 109 + 7.
Note:
Implement the function; do not print anything as it is handled internally.
AnswerBot
3d
Calculate the number of ways Preeti can purchase items within budget, with at least one item quantity differing.
Use dynamic programming to calculate the number of ways to purchase items within budget....read more
Help your peers!
Add answer anonymously...
Top Barclays Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Barclays Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app