Company: Salesforce_12nov
Difficulty: medium
Updating Salesforce Logs Problem Description In a Salesforce environment, optimize the customer interaction logging service by transforming the service's data structure as follows: Optimize the interaction log by repeatedly updating the entries based on a specific transformation logic. This optimization will enhance the service's ability to efficiently retrieve and process historical customer data. The log is updated according to the following steps: 1. For each index i from 0 to iterations - 1: Calculate two indices: i1 = i % n (current position) (% is modulo operation) i2 = n - (i % n) - 1 (symmetric position) Update log[i1] with the result of the bitwise XOR operation between log[i1] and log[i2]. 2. Return the updated log array. Examples Example 1: Input: n = 4, log = [5, 6, 7, 8], and iterations = 3. Output: [3, 1, 6, 8] Explanation: i | i1 | i2 | log[i1] | log[i2] | XOR | log' ---|----|----|---------|---------|-----|----------- 0 | 0 | 3 | 5 | 8 | 13 | [13, 6, 7, 8] 1 | 1 | 2 | 6