fork download
  1. //function for problem
  2. int maxSubarrayXOR(int arr[], int n)
  3. {
  4. int ans = INT_MIN; // Initialize result
  5.  
  6. // Pick starting points of subarrays
  7. for (int i=0; i<n; i++)
  8. {
  9. int curr_xor = 0; // to store xor of current subarray
  10.  
  11. // Pick ending points of subarrays starting with i
  12. for (int j=i; j<n; j++)
  13. {
  14. curr_xor = curr_xor ^ arr[j];
  15. ans = max(ans, curr_xor);
  16. }
  17. }
  18. return ans;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int maxSubarrayXOR(int*, int)’:
prog.cpp:4:15: error: ‘INT_MIN’ was not declared in this scope
     int ans = INT_MIN;     // Initialize result
               ^~~~~~~
prog.cpp:4:15: note: ‘INT_MIN’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
prog.cpp:1:1:
+#include <climits>
 //function for problem
prog.cpp:4:15:
     int ans = INT_MIN;     // Initialize result
               ^~~~~~~
prog.cpp:15:19: error: ‘max’ was not declared in this scope
             ans = max(ans, curr_xor);
                   ^~~
stdout
Standard output is empty