This is a verified interview question from Wigify. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Calculate cost" covers key patterns like Other.
"You are given the prices of N items. You need to remember all the distinct prices. The problem is you can remember at most k distinct prices. If there are some prices of the items still left to remember, then you need to pay X for each of the prices. There are T test cases. For each test case, calculate the cost you need to pay. ### Input format: First line consists of a number T, number of test cases. For each test cases, first line consists of a number N, the total number of items. Second line consists of a number k, maximum distinct prices you can remember. Third line consists of a number X, cost of each price that you were not able to remember. Fourth line consists of N numbers, separated by a space, denoting the prices of N items. ### Output format: Output the cost that you need to pay for the prices that you were not able to remember."
Join thousands of developers practicing for Wigify.