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
4mo
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...
Barclays Software Developer interview questions & answers
A Software Developer was asked 8mo agoQ. What is the difference between static and final?
A Software Developer was asked 8mo agoQ. What is data encapsulation?
A Software Developer was asked 8mo agoQ. Is multiple inheritance allowed in Java?
Popular interview questions of Software Developer
A Software Developer was asked 8mo agoQ1. What is the difference between static and final?
A Software Developer was asked 8mo agoQ2. What is data encapsulation?
A Software Developer was asked 8mo agoQ3. Is multiple inheritance allowed in Java?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

