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, considering distinct ways.
Use dynamic programming to calculate the number of ways to purchase items within budget
Consider differen...read more
Help your peers!
Add answer anonymously...
Google Software Developer interview questions & answers
A Software Developer was asked 1mo agoQ. What are your goals?
A Software Developer was asked 2mo agoQ. What is Dijkstra's algorithm and how does it work?
A Software Developer was asked 2mo agoQ. What is the explanation of the Least Recently Used (LRU) cache algorithm?
Popular interview questions of Software Developer
A Software Developer was asked 1mo agoQ1. What are your goals?
A Software Developer was asked 2mo agoQ2. What is Dijkstra's algorithm and how does it work?
A Software Developer was asked 2mo agoQ3. What is the explanation of the Least Recently Used (LRU) cache algorithm?
Top HR questions asked in Google Software Developer
A Software Developer was asked 2mo agoQ1. Why should we choose you?
A Software Developer was asked 3mo agoQ2. How does the role fit your career plans?
A Software Developer was asked 8mo agoQ3. Explain your project in detail.
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

