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.

AnswerBot
4mo
The challenge involves calculating bills for customers on Black Friday based on discounts for every 'Nth' customer.
Implement 'blackFriday' function to initialize discount for every Nth customer
Impleme...read more
Help your peers!
Add answer anonymously...
Cognizant Trainee Analyst interview questions & answers
A Trainee Analyst was asked 1mo agoQ. What is the highest background
A Trainee Analyst was asked Q. Ninja and His Secret Information Encoding Problem Ninja, a new member of the FBI...read more
A Trainee Analyst was asked Q. Minimum Stops for Ninja's Journey Problem Statement Ninja wishes to travel from ...read more
Popular interview questions of Trainee Analyst
A Trainee Analyst was asked 1mo agoQ1. What is the highest background
A Trainee Analyst was asked Q2. Ninja and His Secret Information Encoding Problem Ninja, a new member of the FBI...read more
A Trainee Analyst was asked Q3. Minimum Stops for Ninja's Journey Problem Statement Ninja wishes to travel from ...read more
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

