SALESFORCE Coding Question – Solved

12 Live
In a Salesforce environment, there are n developers working on a collaborative task in a workspace, where they plan to transfer a debug log sequentially. Each developer has a unique ID in the range of 1 to n, inclusive. The developer with ID i will always transfer the log to the developer specified at logReceiver[i], and this transfer occurs every second. Developer 1 always starts with the debug log, and a developer always transfers the log to another developer. Determine which developer has the debug log after k seconds have passed. Example: logReceiver = [2, 4, 1, 5, 3], k = 6. After 6 seconds, the debug log will be with developer 2. Function Description: Complete the function logTransferReceiver in the editor below. logTransferReceiver has the following parameters: int logReceiver[n]: the i-th developer will transfer the debug log to the developer indicated in logReceiver[i]. int k: the duration (in seconds) for which the log is being transferred. Return: int: the developer holding the debug log at time = k. Constraints: 2 ≀ n ≀ 2Γ—10^5 1 ≀ logReceiver[i] ≀ n (logReceiver[i] β‰  i) 1 ≀ k ≀ 10^12 Input Format For Custom Testing: Sample Case 0: logReceiver[] size n = 4 logReceiver = [3, 1, 4, 2] Sample Input For Custom Testing: STDIN 2 5 Sample Output: k = 5 2 Explanation: The log is transferred in the following sequence, starting with Developer 1 at time = 0:

Asked in: SALESFORCE

Image of the Question

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