JAVA|| 1 LINER CODE || 100 % FASTER || 2 APPROACH EXPLAINED
PLEASE UPVOTE IF YOU LIKE THIS\n\n# Code\n\nFirst Approach:\n\nTime complexity : O(N);\nSpace complexity: O(N);\n\nclass Solution {\n    public int[] findArray(
**PLEASE UPVOTE IF YOU LIKE THIS**\n\n# Code\n```\nFirst Approach:\n\nTime complexity : O(N);\nSpace complexity: O(N);\n\nclass Solution {\n    public int[] findArray(int[] pref) {\n        int[] res = new int[pref.length];\n        for (int i = 0, j = 1; i < pref.length - 1; i++, j++) {\n            int storeValue = pref[j];\n            res[j] = pref[i] ^ pref[j];\n        }\n        res[0] = pref[0];\n        return res;\n    }\n}\n```\n```\nSecond Approach:\n\nTime complexity : O(N);\nSpace complexity: O(1);\n\npublic static int[] findArray(int[] pref) {\n        for(int i = pref.length - 1; i > 0; i--) pref[i] = pref[i] ^ pref[i-1];\n        return pref;\n    }\n```
['Java']