diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/decode_xor_array.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/decode_xor_array.cpp')
-rw-r--r-- | other/decode_xor_array.cpp | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/other/decode_xor_array.cpp b/other/decode_xor_array.cpp deleted file mode 100644 index 7ee4139..0000000 --- a/other/decode_xor_array.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// 720. Decode XORed Array -#include "leetcode.h" - -/* - * there is a hidden integer array 'arr' that consists of 'n' non-negative - * integers. it was encoded into another integer array 'encoded' of length 'n - - * 1' such that 'encoded[i] = arr[i] ^ arr[i + 1]'. for example, if 'arr = - * [1,0,2,1]', then 'encoded = [1,2,3]'. you are given the 'encoded' array. you - * are also given an integer 'first', that is the first element of 'arr'. ie. of - * 'arr[0]'. return the original array 'arr'. it can be proved that the answer - * exists and is unique. - */ - -class Solution { -public: - vector<int> decode(vector<int> encoded, int first) { - for (int &i : encoded) { - swap(i, first); - first ^= i; - } - encoded.push_back(first); - return encoded; - } -}; - -int main() { - Solution obj; - vector<int> e1 = {1, 2, 3}, e2 = {6, 2, 7, 3}; - for (auto i : obj.decode(e1, 1)) - printf("%d ", i); // expect: 1 0 2 1 - printf("\n"); - for (auto i : obj.decode(e2, 4)) - printf("%d ", i); // expect: 4 2 0 7 4 - printf("\n"); -} |