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

Vaibhav Mali
2y

Algorithm:

Create an integer “answer” equal to 0.

First iterate over the list of pants, for each pant:

Then, iterate over the list of shirts, for each shirt:

Then, iterate over the list of shoes...read more

Help your peers!
Select
Add answer anonymously...

Top Software Developer Interview Questions Asked at Wipro

Q. What is async and await?
Q. What is an operating system?
Q. What are the concepts of Object-Oriented Programming (OOP)?
Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits