-1
public class Solution {
    public static int solution(int[] x, int[] y) {

        // for every value in x
        for (int v : x){
            // check if value exists in y
            boolean i = y.contains(v);
            // if indicator returns false the value is returned
            if (i == false){
                int r = v;
            }

        }

Solution.java:8: error: cannot find symbol boolean i = y.contains(v); ^ symbol: method contains(int) location: variable y of type int[]

1 Answers1

1

As pointed out in the comment, arrays in java don't have contains() method. But if the arrays x and y are already sorted, how about using Arrays.binarySearch(y,v) ? If the value v is present, you would get the index at which v is present in array y. Otherwise you would get negative value

Kavitha Karunakaran
  • 1,340
  • 1
  • 17
  • 32