Education + Jobs Hiring Website - 2025
0 like 0 dislike
411 views

**Q1: **
A system manages several tasks. There is a string taskQueue containing n tasks, where each task has a priority level represented as follows: '1' for low, '2' for medium, and '3' for high. To optimize the system, the following operations can be performed any number of times:

Swap adjacent tasks with values '1' and '2' (or vice versa).

Swap adjacent tasks with values '2' and '3' (or vice versa).

Determine the lexicographically smallest order of the task Queue.

Note: A task order a is lexicographically smaller than a task order b if and only if in the first position where a and b differ, the task order a has a lower priority task than b.

Q2:
A store offers n items, each with a price specified in the array price[i]. A customer has m discount coupons. When x coupons are applied to the ith item, its price is reduced to floor(price[i]/2).

Determine the minimum total cost to purchase all items by optimally allocating at most m discount coupons.

Example

Consider n = 2, price = [2, 4], m = 2.

The optimum solution:

Purchase item 1 for 2.

Use 2 coupons on item 2. so the discounted price is 4/22 = 4 /4=1.

The amount required = 2+1=3.

Function Description

Complete the function findMinimumPrice in the editor with the following parameters:

int price[n]: the original prices of the items

int m: the number of discount coupons

Returns

int: the minimum amount of money needed to buy all n items

Q3:
image.png

It will be really helpful, if you guys can can help in providing sol. for above questions.

OA duration: 1hr 15 min

in Online Assessments by Expert (146,210 points)
edited by | 411 views

Please log in or register to answer this question.

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .