import java.util.*;
import java.lang.*;
class Main
{
{
int[] a = new int[] { 1, 2, 4 };
int[] b = new int[] {1, 3, 4, 1 };
System.
out.
println( duplicates
( a, a.
length )); System.
out.
println( duplicates
( b, b.
length ));
}
public static boolean duplicates (int [] x, int numElementsInX ) {
Set<Integer> set = new HashSet<Integer>();
for ( int i = 0; i < numElementsInX; ++i ) {
if ( set.contains( x[i])) {
return true;
}
else {
set.add(x[i]);
}
}
return false;
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CgpjbGFzcyBNYWluCnsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludFtdIGEgPSBuZXcgaW50W10geyAxLCAyLCA0IH07CiAgICAgICAgaW50W10gYiA9IG5ldyBpbnRbXSB7MSwgMywgNCwgMSB9OwogICAgICAgIAogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbiggZHVwbGljYXRlcyggYSwgYS5sZW5ndGggKSk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCBkdXBsaWNhdGVzKCBiLCBiLmxlbmd0aCApKTsKICAgICAgICAKCX0KICAgIAogICAgcHVibGljIHN0YXRpYyBib29sZWFuIGR1cGxpY2F0ZXMgKGludCBbXSB4LCBpbnQgbnVtRWxlbWVudHNJblggKSB7CiAgICAgICAgU2V0PEludGVnZXI+IHNldCA9IG5ldyBIYXNoU2V0PEludGVnZXI+KCk7CiAgICAgICAgZm9yICggaW50IGkgPSAwOyBpIDwgbnVtRWxlbWVudHNJblg7ICsraSApIHsKICAgICAgICAgICAgaWYgKCBzZXQuY29udGFpbnMoIHhbaV0pKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIHNldC5hZGQoeFtpXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgCn0=