Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Finder {
- static int MissingElement(int[] array, int[] array2) {
- int x = 0, counter = 0;
- for (int i = 0; i < array.length; i++) {
- if (counter == 1) { break; }
- x = array[i];
- for (int j = 0; j < array2.length; j++) {
- if (x == array2[j]) { counter = 2; break; } else { counter = 1; }
- }
- } return x;
- }
- public static void main (String[] args) {
- int[] array = {4, 8, 12, 9, 3};
- int[] array2 = {4, 8, 9, 3};
- System.out.println("Missing element: " + Finder.MissingElement(array, array2));
- }
- }
Add Comment
Please, Sign In to add comment