You are given an integer array log of size n and an integer iterations.
For each iteration i from 0 to iterations - 1, compute index = i mod n. Let symmetric = n - index - 1. Update log[index] to log[index] XOR log[symmetric].
Return the final array after all iterations are complete.
Examples
01 · Example 1
log = [1, 2, 3] iterations = 2 return = [2, 0, 3]
Iteration 0 updates index 0: 1 XOR 3 = 2. Iteration 1 updates the middle index: 2 XOR 2 = 0.
02 · Example 2
log = [4, 7, 1, 2] iterations = 5 return = [2, 6, 7, 4]
Applying the five updates at indices 0,1,2,3,0 produces [2,6,7,4].
Constraints
1 <= log.length0 <= iterations
More Salesforce problems
- Key Teams in TreeOA · Seen Mar 2026
- System Energy ReductionOA · Seen Mar 2026
- Count Palindromic Concatenation PairsOA · Seen Mar 2026
- Collect Opportunity Data in a TreeOA · Seen Feb 2026
- Replace '?' to Avoid Adjacent DuplicatesOA · Seen Feb 2026
- Strings With No k Consecutive Identical CharactersOA · Seen Feb 2026
- Spam ClassificationSeen Jun 2025
- Longest Subsequence which is a SubstringSeen Jun 2025
public int[] updateLogsBySymmetricXor(int[] log, long iterations) {
// write your code here
}log[1, 2, 3]
iterations2
expected[2, 0, 3]
sign in to submit