I can only edit the class
Solution
and the method inside it.
The input will be given by the problem only.
further details: I basically have to create a method in a class which accepts two arrays or whatever that input is trying to say and pick out one element which is extra in one of them.
my Code:
import java.util.Arrays;
public class Solution {
public static int solution(int[] x, int[] y) {
// Your code here
int[] shorter = (x.length>y.length)? y : x;
int[] longer = (x.length>y.length)? x : y;
Arrays.sort(shorter);
Arrays.sort(longer);
for(int i=0; i<shorter.length; i++){
if(shorter[i]!=longer[i]){
//System.out.println(longer[i]);
return longer[i];
}
else {
// System.out.println(longer[longer.length-1]);
return longer[longer.length-1];
}
}
return 0;
}
}
The input that they are giving refers to the arrays which are missing new int[] ...