Company: Salesforce_4th june_on campus _iit guwahti
Difficulty: medium
A multi-region cloud platform operates a circular ring of m servers, numbered from 1 to m, where servers 1 and m sit next to each other. These servers handle a variety of customer requests, and the array transitionTime[i] gives the time needed to hop from the ith server over to either of its two neighbors. A sequence of requested servers (given as an array of length n, requestedServers) must be visited in that exact order to process a batch of customer workloads. Determine the least total time needed to process every request, starting from server 1. Example m = 3 n = 4 transitionTime = [3, 2, 1] requestedServers = [1, 3, 3, 2] The pointer starts at server 1, and the first requested server is also 1, so visiting it costs 0 seconds. Moving from server 1 to 3 could follow the path 1 → 2 → 3, costing 3 + 2 = 5 seconds, or the path 1 → 3, costing 3 seconds. Taking the cheaper route, server 3 is reached in 3 seconds. The pointer is already at server 3, so the third requested s