Sobes.tech
Junior — Senior

Determining the missing element in an array after deletion

livecode

Task condition

There are two arrays:

  1. The original array containing a set of numbers.
  2. A copy of the first array, from which exactly one number has been removed. It is necessary to write a function that determines and returns the removed value.
public class Numbers {
    public static void main(String[] args) {
        assert(diff(new int[]{4, 2, 3, 6}, new int[]{2, 3, 4}) == 6);
        assert(diff(new int[]{1, 2, 2}, new int[]{2, 1}) == 2);
    }

    private static int diff(int[] beforeRemove, int[] afterRemove) {
        //todo: not implemented
    }
}