public class Solution {
public int[] Decode(int[] encoded, int first) {
var list = new List<int>();
var hidden = first;
list.Add(hidden);
foreach (var enc in encoded) {
hidden ^= enc;
list.Add(hidden);
}
return list.ToArray();
}
}
Source:
https://leetcode.com/problems/decode-xored-array/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Monday, February 15, 2021
Leetcode Everyday: 1720. Decode XORed Array. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment