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 static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. int A[] = {1,2,3};
  14. int A1[] = {2,3};
  15. int A2[] = {1,3};
  16. int A3[] = {1,2};
  17. System.out.println("A1:"+method(A,A1));
  18. System.out.println("A2:"+method(A,A2));
  19. System.out.println("A3:"+method(A,A3));
  20. }
  21. public static int method(int a[], int b[]) {
  22. int missing = -999;
  23. int left = 0;
  24. int right = a.length()-1;
  25. int middle = (left + right)/2;
  26. while(middle>=left && middle<=right) {
  27. middle = (left + right)/2;
  28. if(a[middle]==b[middle]){
  29. left = middle+1;
  30. }else if(a[middle]<b[middle]){
  31. if(left == right){
  32. missing = a[left];
  33. break;
  34. }
  35. right = middle -1;
  36. }
  37. }
  38. return missing;
  39. }
  40.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:39: error: reached end of file while parsing
}
 ^
1 error
stdout
Standard output is empty