728x90
반응형
Solution
- Use principle : A ^ B = C -> A ^ C = B
class Solution {
public:
vector<int> decode(vector<int>& encoded, int first) {
vector<int> res;
res.push_back(first);
for (int i = 0; i != encoded.size(); ++i)
{
res.push_back(res.back() ^ encoded[i]);
}
return res;
}
};
728x90
반응형
'코딩 문제' 카테고리의 다른 글
| LeetCode 1768 Merge String Alternately (0) | 2023.07.17 |
|---|---|
| [LeetCode] 771, Jewels and Stones (2) | 2023.02.14 |
| [LeetCode] 728. Self Dividing Numbers, C++ (0) | 2023.01.26 |
| [LeetCode] 2032. Two Out of Three, C++ (1) | 2023.01.25 |
| [Leet Code] 231. Power of Two, C++ (0) | 2023.01.17 |