SALESFORCE Coding Question – Solved

9 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

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