/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
// your code goes here
// arr = {56, 25, 13, 7, 56, 38, 7}
// output {56, 7} // duplicates
HashSet<Integer> set = new HashSet<>();
int arr[] = new int[] {56, 25, 13, 7, 56, 38, 7};
ArrayList<Integer> res = new ArrayList<>();
for(int x: arr) {
if(set.contains(x)) {
res.add(x);
}
else {
set.add(x);
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCQkvLyBhcnIgPSB7NTYsIDI1LCAxMywgNywgNTYsIDM4LCA3fQoJCS8vIG91dHB1dCB7NTYsIDd9IC8vIGR1cGxpY2F0ZXMKCQlIYXNoU2V0PEludGVnZXI+IHNldCA9IG5ldyBIYXNoU2V0PD4oKTsKCQlpbnQgYXJyW10gPSBuZXcgaW50W10gezU2LCAyNSwgMTMsIDcsIDU2LCAzOCwgN307CgkJQXJyYXlMaXN0PEludGVnZXI+IHJlcyA9IG5ldyBBcnJheUxpc3Q8PigpOwoJCWZvcihpbnQgeDogYXJyKSB7CgkJCWlmKHNldC5jb250YWlucyh4KSkgewoJCQkJcmVzLmFkZCh4KTsKCQkJfQoJCQllbHNlIHsKCQkJCXNldC5hZGQoeCk7CgkJCX0KCQl9CgkJCgkJU3lzdGVtLm91dC5wcmludGxuKHJlcyk7CgkJCgl9Cn0=