Amazon Coding Question – Solved

8 Live
Company is focused on using sophisticated algorithms to optimize inventory turnover within its warehouse network. In this case, you're given a task related to a specific operation with an array of inventory levels. Formally, you are given an array of positive integers, inventoryLevels, of size n. Additionally, you have two positive integers x and y, with x being equal to or smaller than y. You can apply an inventory operation on inventoryLevels any number of times, potentially not at all. The inventory operation involves selecting two distinct indices i and j within the array (0 < i, j< n), incrementing the value at index / in inventoryLevels by x, and decreasing the value at index j in inventoryLevels by y. Find the maximum possible value for the smallest level in inventoryLevels after the operations are performed. Note: It is possible that while performing operations, elements become negative. However, after the completion of all the operations on inventoryLevels, each value should within the array should be greater than 0. Example n=3 InventoryLevels = [11, 1, 2] X=2 y=3

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |