text: Remove one element to get maximum XOR | C # implementation of the approach ; Function to return the maximized XOR after removing an element from the array ; Find XOR of the complete array ; To store the readonly answer ; Iterating through the array to find the readonly answer ; Return the readonly answer ; Driver code
code: using System ; class GFG { static int maxXOR ( int [ ] arr , int n ) { int xorArr = 0 ; for ( int i = 0 ; i < n ; i ++ ) xorArr ^= arr [ i ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans = Math . Max ( ans , ( xorArr ^ arr [ i ] ) ) ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 3 } ; int n = arr . Length ; Console . WriteLine ( maxXOR ( arr , n ) ) ; } }