Very Unique easy ways to Tackle this problem C++ / C# / python3 / Java / C / Python / Swift
Intuition\n\n\n\n\n\n\nC++ []\nclass Solution {\npublic:\n    vector<int> findArray(vector<int>& pref) {\n        vector<int> arr(pref.size(), 0);\n        arr[
# Intuition\n![Screenshot 2024-03-26 101321.png](https://assets.leetcode.com/users/images/44a9b46a-663e-49bd-b191-4cca102da325_1711428580.1562343.png)\n![Screenshot 2024-03-26 101400.png](https://assets.leetcode.com/users/images/7a86ffda-9419-4c8f-994f-e55df11fcce4_1711428587.8263817.png)\n![Screenshot 2024-03-26 101154.png](https://assets.leetcode.com/users/images/edb905d4-6eeb-4909-890f-699eb019abc0_1711428593.397745.png)\n![Screenshot 2024-03-26 101229.png](https://assets.leetcode.com/users/images/7316755c-ae3a-4ac1-b1da-0a4a2f447039_1711428598.0530617.png)\n![Screenshot 2024-03-26 101256.png](https://assets.leetcode.com/users/images/e0611941-7aa3-49d6-931f-cf02a623c9f0_1711428603.8087237.png)\n![Screenshot 2024-03-26 101120.png](https://assets.leetcode.com/users/images/b5595c9e-6769-40f3-b8d4-bfef39c363e0_1711428610.0266905.png)\n```C++ []\nclass Solution {\npublic:\n    vector<int> findArray(vector<int>& pref) {\n        vector<int> arr(pref.size(), 0);\n        arr[0] = pref[0];\n        for (int i = 1; i < pref.size(); ++i)\n            arr[i] = pref[i - 1] ^ pref[i];\n        return arr;\n    }\n};\n```\n```python3 []\nclass Solution:\n    def findArray(self, pref: List[int]) -> List[int]:\n        arr = [0] * len(pref)\n        arr[0] = pref[0]\n        for i in range(1, len(pref)):\n            arr[i] = pref[i - 1] ^ pref[i]\n\n        return arr\n```\n```C []\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* findArray(int* pref, int prefSize, int* returnSize) {\n    int* arr = malloc(sizeof(int) * prefSize);\n    arr[0] = pref[0];\n    for (int i = 1; i < prefSize; ++i)\n        arr[i] = pref[i - 1] ^ pref[i];\n    *returnSize = prefSize;\n    return arr;\n}\n```\n```java []\nclass Solution {\n    public int[] findArray(int[] pref) {\n        int arr[] = new int[pref.length];\n        arr[0] = pref[0];\n        for (int i = 1; i < pref.length; ++i)\n            arr[i] = pref[i - 1] ^ pref[i];\n        return arr;\n    }\n}\n```\n```python []\nclass Solution(object):\n    def findArray(self, pref):\n        """\n        :type pref: List[int]\n        :rtype: List[int]\n        """\n        arr = [0] * len(pref)\n        arr[0] = pref[0]\n        for i in range(1, len(pref)):\n            arr[i] = pref[i - 1] ^ pref[i]\n\n        return arr\n```\n```C# []\npublic class Solution {\n    public int[] FindArray(int[] pref) {\n        int []arr = new int[pref.Length];\n        arr[0] = pref[0];\n        for (int i = 1; i < pref.Length; ++i)\n            arr[i] = pref[i - 1] ^ pref[i];\n        return arr;\n    }\n}\n```\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n)\n# Code\n```\npublic class Solution {\n    public int[] FindArray(int[] pref) {\n        int []arr = new int[pref.Length];\n        arr[0] = pref[0];\n        for (int i = 1; i < pref.Length; ++i)\n            arr[i] = pref[i - 1] ^ pref[i];\n        return arr;\n    }\n}\n```\n# Please find my solution & upvote although you don\'t need a solution for this question\n![th.jpeg](https://assets.leetcode.com/users/images/11670251-afa3-440c-85aa-4a9fb24cbf37_1711428864.727829.jpeg)\n
['Stack', 'C', 'Python', 'C++', 'Java', 'Python3', 'C#']