Shopping Options Problem Statement
Given arrays representing the costs of pants, shirts, shoes, and skirts, and a budget amount 'X', determine the total number of valid combinations that can be purchased such that the total cost does not exceed 'X'. Each purchase must include exactly 1 item from each list.
Input:
The first line contains an integer ‘T’ denoting the number of test cases. Each test case consists of:
- Five integers ‘P’, ‘Q’, ‘R’, ‘S’, and ‘X’, representing the number of pants, shirts, shoes, skirts, and the budget amount, respectively.
- The second line contains ‘P’ integers, denoting the cost of each pant.
- The third line contains ‘Q’ integers, denoting the cost of each shirt.
- The fourth line contains ‘R’ integers, denoting the cost of each shoe.
- The fifth line contains ‘S’ integers, denoting the cost of each skirt.
Output:
For each test case, return an integer that represents the total number of valid combinations. Each result should be output on a new line.
Example:
Example input not provided in the original prompt.
Constraints:
1 <= T <= 100
1 <= P, Q, R, S <= 10
1 <= X <= 10^9
1 <= pants[i], shirts[i], shoes[i], skirts[i] <= 10^9
Note:
You do not need to print anything. Focus on implementing the required function to return the results.

AnswerBot
4mo
Determine total number of valid shopping combinations within budget
Iterate through all possible combinations of items from each array
Check if the total cost of the combination is within the budget
Retu...read more
Help your peers!
Add answer anonymously...
Amazon SDE-2 interview questions & answers
A SDE-2 was asked Q. Given a binary tree where each node contains a digit from 0-9, find the sum of a...read more
A SDE-2 was asked Q. Write a program to perform a preorder traversal of a binary tree without using r...read more
A SDE-2 was asked Q. Write code to find the median of an unsorted array.
Popular interview questions of SDE-2
A SDE-2 was asked Q1. Given a binary tree where each node contains a digit from 0-9, find the sum of a...read more
A SDE-2 was asked Q2. Write a program to perform a preorder traversal of a binary tree without using r...read more
A SDE-2 was asked Q3. Write code to find the median of an unsorted array.
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

