JPMORGAN Coding Question – Solved

7 Live
A company needs an efficient strategy to optimize resource allocation for servers based on performance metrics. The performance of each server is represented by performance[i], where 0 ≀ i < n. A server's rank is defined by the count of distinct performance metrics that are greater than or equal to its own performance metric. To allocate resources, two positive integer constants, inc and dec, are used to determine increment and decrement values, respectively. The resource allocation for each server is calculated as follows: resource allocation = inc Γ— (n + 1 - server's rank) - dec Γ— rank The task is to calculate the resource allocation for each server based on their performance. Example: inc = 500 dec = 100 n = 6 performance = [3, 2, 4, 3, 5, 5] Server index 0 has a rank of 3 since 3, 4, and 5 are greater than or equal to its performance of 3. The resource allocation is calculated as: 500 Γ— (6 + 1 - 3) - 100 Γ— 2 = 1800

Asked in: JPMORGAN

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… |