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. int a[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 20, 21, 23 };
  13. printMissing(a);
  14. }
  15.  
  16. public static void printMissing(int[] array) {
  17.  
  18. final int lastNum = array[array.length-1];
  19. final int firstNum = array[0];
  20. int pos = 0;
  21.  
  22. System.out.println("These are missing: ");
  23. for (int i = firstNum; i < lastNum; ++i) {
  24. if(array[pos] != i){
  25. System.out.println(i);
  26. }else {
  27. pos++;
  28. }
  29. }
  30. }
  31. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
These are missing: 
5
16
17
19
22