Guest User

Untitled

a guest
Jan 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public class Finder {
  2. static int MissingElement(int[] array, int[] array2) {
  3. int x = 0, counter = 0;
  4. for (int i = 0; i < array.length; i++) {
  5. if (counter == 1) { break; }
  6. x = array[i];
  7. for (int j = 0; j < array2.length; j++) {
  8. if (x == array2[j]) { counter = 2; break; } else { counter = 1; }
  9. }
  10. } return x;
  11. }
  12.  
  13. public static void main (String[] args) {
  14. int[] array = {4, 8, 12, 9, 3};
  15. int[] array2 = {4, 8, 9, 3};
  16. System.out.println("Missing element: " + Finder.MissingElement(array, array2));
  17. }
  18. }
Add Comment
Please, Sign In to add comment