Optimized In-Place Solution | Beats 100% | O(1) Space 
Intuition

The given pref array represents the prefix XOR of an original array.


We need to reconstruct the original array directly within the pref array itsel
# Intuition
- The given `pref` array represents the prefix XOR of an original array. 
- We need to reconstruct the original array directly within the `pref` array itself to optimize space usage.  
- Observing the properties of XOR, we can derive the original elements using:  
    arr[i] = pref[i] ^ pref[i-1]

- By modifying `pref` in place, we eliminate the need for extra space.

# Approach  
1. Iterate from the last index down to `1`, updating `pref[i]` using:  
   pref[i] = pref[i - 1] ^ pref[i]
  
2. Return `pref`, which now holds the reconstructed array in place.  

# Complexity
- **Time Complexity:**  
   O(n) — We iterate through the array once.
- **Space Complexity:**  
   O(1)  — In-place modification without extra space.

# Code
```java []
class Solution {
    public int[] findArray(int[] pref) {

        //Optimized approach: Modifying the input array in place to avoid extra space
        int n = pref.length;
        
        // Computing the original array in-place
        for(int i = n - 1; i > 0;i--){
            pref[i] = pref[i - 1] ^ pref[i];
        }

        return pref;// answer
    }
}
```

```python []
def findArray(pref):
    n = len(pref)
    
    # Compute the original array in-place
    for i in range(n - 1, 0, -1):
        pref[i] = pref[i - 1] ^ pref[i]

    return pref  # The modified pref now represents the original array


```

```C++ []
#include <vector>

class Solution {
public:
    std::vector<int> findArray(std::vector<int>& pref) {
        int n = pref.size();

        // Computing the original array in-place
        for (int i = n - 1; i > 0; i--) {
            pref[i] = pref[i - 1] ^ pref[i];
        }

        // The modified pref now represents the original array
        return pref; 
    }
};
```



```javascript []
var findArray = function(pref) {
    let n = pref.length;
    
    // Compute the original array in-place
    for (let i = n - 1; i > 0; i--) {
        pref[i] = pref[i - 1] ^ pref[i];
    }

    return pref; // The modified pref now represents the original array
};

```

['Array', 'Bit Manipulation', 'C++', 'Java', 'JavaScript']