One of my friend was asked this question in an interview -
Given two arrays say A1 of size 'n' and A2 of size 'n-1', both the arrays have same element except one which we have to find.
Note: elements in A1 can be repeated.
Example:
A1:{2,5,5,3}
A2:{2,5,3}
Output: 5
A1:{1,2,3,3,3}
A2:{2,3,1,3}
Output: 3
public static void main(String args[])
{
int[] a ={1,2,3,3,3};
int[] b ={2,3,1,3};
int flag=1;
int num=0;
List lst = new ArrayList<>(b.length);
for(int i : b)
lst.add(Integer.valueOf(i));
for(int i=0;i