We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int n = i();
int a[] = new int[1001];
int sum = 0;
for(int i=1;i<=n;i++)
a[i()]++;
for(int i=1;i<=n;i++)
{
int v = i();
if(a[v]>0)
{
sum++;
a[v]--;
}
}
if(sum<n)
System.out.print(sum+1);
else
System.out.print(sum-1);
}
**Solution O(n)**
Beautiful Pairs
You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) {