Amazon Coding Question – Solved

2 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

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |