fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public int func(int a[] , int b[]){
  11. int n = a.length;
  12. int m = b.length;
  13.  
  14. int len = -1;
  15. int maxi = Integer.MIN_VALUE;
  16. for(int i=0;i<n;i++){
  17. int z1 = 0;
  18. int z2 = 0;
  19. for(int j=i;j<n;j++){
  20. z1 = z1 ^ a[j];
  21. z2 = z2 ^ b[j];
  22. if(z1 == z2){
  23. len = j-i+1;
  24. maxi = Math.max(maxi,len);
  25. }
  26. }
  27. }
  28. return maxi;
  29. }
  30. public static void main (String[] args) throws java.lang.Exception
  31. {
  32. // your code goes here
  33. Ideone obj = new Ideone();
  34.  
  35. int a[] = {1, 2, 3, 5};
  36. int b[] = {1, 3, 2, 4};
  37.  
  38. int ans = obj.func(a, b);
  39.  
  40. System.out.println(ans);
  41. }
  42. }
Success #stdin #stdout 0.06s 52416KB
stdin
Standard input is empty
stdout
3