SALESFORCE Coding Question – Solved

5 Live
1. Salesforce Cloud server requests In a Salesforce multi-cloud architecture, there is a circular network of m cloud servers, numbered from 1 to m, where servers 1 and m are adjacent. These servers handle various customer requests, and the latency between switching from one server to the next or the previous is given by an array, transitionTime[i], representing the time required to transition from the ith server to its adjacent servers. A sequence of requested servers (represented as an array of length n, requestedServers) must be visited in the given order to handle customer workloads. The task is to determine the minimum time required to process all the requests, starting from server 1. Example: m = 3 n = 4 transitionTime = [3, 2, 1] requestedServers = [1, 3, 3, 2] - The pointer is initially at server 1, and the first server to be visited is number 1, hence it takes 0 seconds to visit it. - To move from server 1 to 3, the path followed could be 1 -> 2 -> 3, which takes 3 + 2 = 5 seconds, or the path could be 1 -> 3, which takes 3 seconds. Choosing the shorter path, server 3 is visited in 3 seconds. - The pointer is already at server 3, so the third server takes no time to visit. - To move from server 3 to 2, either the path could be 3 -> 2, which takes 1 second, or the path could be 3 -> 1 -> 2, which takes 1 + 3 = 4 seconds. Choosing the shorter path, the fourth required server is visited in 1 second after visiting the third server. Hence, the minimum possible time to visit all the required servers is 4 seconds. Function Description: Complete the function minRequestTime in the editor below. minRequestTime takes the following parameter(s): - int requestedServers[n]: the sequence of servers to be visited - int transitionTime[m]: the time taken to switch connections from each server and connect to its adjacent server Returns: - long: the minimum total time required to visit all the requested servers, considering the transition time of servers Constraints: - 1 ≀ requestedServers(i) ≀ m - 1 ≀ m ≀ 1000 - 1 ≀ transitionTime(i) ≀ 10^6

Asked in: SALESFORCE

Image of the Question

Question Image Question Image Question Image Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |