Black Friday Discount Challenge

Imagine it's Black Friday and a supermarket is offering a discount to every 'Nth' customer. You are tasked with calculating bills for customers based on product prices and quantities, factoring in potential discounts for specific customers.

Function Descriptions:

  • blackFriday(int N, int discount, int[] products, int[] prices): Initializes with every Nth customer receiving a discount, 'discount' is the percentage, 'products' array contains product IDs, and 'prices' array has product prices.
  • generateBill(int[] productID, int[] quantity): Takes 'productID' and 'quantity' arrays to calculate the total bill for each customer's purchase.

Input:

The first input line contains an integer 'T', the number of test cases.
For each test case:
- The first line contains 'N' (discount interval), 'discount' (percentage), and 'S' (number of products).
- The next line has 'S' space-separated integers for the 'products' array.
- The following line has 'S' space-separated integers for the 'prices' array.
- Then, an integer 'K', the number of customer queries.
For each of the 'K' queries:
- An integer 'S' for the number of distinct products purchased.
- 'S' space-separated integers for the 'productID' array.
- 'S' space-separated integers for the 'quantity' array.

Output:

For each customer in each test case, return a list of the final bill amount considering the discount, in the order bills are generated. Each test case's output should be on a separate line.

Example:

Input:
T = 1
N = 3
discount = 25
S = 2
products = [1, 2]
prices = [100, 200]
K = 2
S = 1
productID = [1]
quantity = [2]
S = 2
productID = [1, 2]
quantity = [1, 1]
Output:
[200.00000, 300.00000]

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ K ≤ 1000
  • 1 ≤ S ≤ 100
  • 1 ≤ productID[i], products[i], quantity[i], prices[i] ≤ 1000

Note: You are not required to print anything; just implement the functions to return the results.

Be the first one to answer
Add answer anonymously...
Cognizant Trainee Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter