FastPrepUpdate Logs by Symmetric XOR
Problems/Update Logs by Symmetric XOR

Update Logs by Symmetric XOR

Salesforce logoSalesforceFULLTIMEOA

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given an integer array log of size n and a non-negative integer iterations.

The updates are applied sequentially and in-place. For each iteration i from 0 to iterations - 1:

  1. Compute index = i mod n.
  2. Compute symmetric = n - index - 1.
  3. Set log[index] = log[index] XOR log[symmetric], using the current array values at that moment.

If index == symmetric, the element is updated to 0 because x XOR x = 0. Return the final array after all iterations are complete. Since iterations can be very large, solutions should reason about the repeated index cycle instead of simulating every iteration one by one.

Function

updateLogsBySymmetricXor(log: int[], iterations: long) → int[]

Examples

Example 1

log = [1, 2, 3]iterations = 2return = [2, 0, 3]

Iteration 0 updates index 0: 1 XOR 3 = 2, so the array becomes [2,2,3]. Iteration 1 updates the middle index, where index == symmetric, so 2 XOR 2 = 0. The result is [2,0,3].

Example 2

log = [4, 7, 1, 2]iterations = 5return = [2, 6, 7, 4]

The updates are in-place at indices 0,1,2,3,0. The array changes as [4,7,1,2] -> [6,7,1,2] -> [6,6,1,2] -> [6,6,7,2] -> [6,6,7,4] -> [2,6,7,4].

Constraints

  • 1 <= log.length <= 2 * 10^5
  • 0 <= log[i] <= 10^9
  • 0 <= iterations <= 10^18

More Salesforce Online Assessment questions

  • Count Subarrays With Product Equal to KOA · Seen Nov 2026
  • Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
  • Get Message StatusOA · Seen Nov 2026
  • Minimum Unique-Character Segments After DeletionOA · Seen Sep 2026
  • Run-Length String CompressionOA · Seen Sep 2026
  • Maximum Requests in WindowOA · Seen Sep 2026
  • Final Pod Counts After LogsOA · Seen Aug 2026
  • Minimum Removals to Balance ArrayOA · Seen Aug 2026
  • Is This Date a Weekend?OA · Seen Aug 2026
  • Maximum Barbell WeightOA · Seen Jul 2026

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public int[] updateLogsBySymmetricXor(int[] log, long iterations) {
      // write your code here
    }
}
Checking account…