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 arr[]={2,3,1,-2,7,7,8,8,-2,3,4};
  13. int res[]=action(arr);
  14. for (int i=0; i<res.length; i++) System.out.print(res[i]+" ");
  15. }
  16. public static int [] action(int [] inArr)
  17. {
  18. int n=inArr.length;
  19. int [] res = new int [n-1];
  20. int min=inArr[0];
  21. int pmin=0;
  22. int i,j;
  23. for (i=1; i<n; i++)
  24. {
  25. if (inArr[i]<=min)
  26. {
  27. min=inArr[i];
  28. pmin=i;
  29. }
  30. }
  31. for (i=j=0; i<n; i++)
  32. if (i!=pmin) res[j++]=inArr[i];
  33. return res;
  34. }
  35. }
Success #stdin #stdout 0.03s 2184192KB
stdin
Standard input is empty
stdout
2 3 1 -2 7 7 8 8 3 4