Contains Duplicate

Practice this coding question on Coding Gurukul.

Problem statement

A lab imports a batch of integer equipment codes from several inventory files. Before accepting the batch, it must check whether any code was entered more than once. The original order need not be changed, and the report only needs to say whether a duplicate exists, rather than list all repeated codes. Your task Given n integers, print true if any value occurs at least twice; otherwise print false. Equal values count as duplicates even when they are far apart. Zero and negative codes follow the same equality rule as positive codes. A batch containing one code has no duplicate. Worked example For [12, -4, 8, 12, 0], code 12 occurs at positions 0 and 3, so print true. For [12, -4, 8, 0], all four codes differ, so print false.

Input format

First line: n. Second line: n space-separated integers.

Output format

Print lowercase true or false.

Constraints

1 <= n <= 100000; -10^9 <= each value <= 10^9.

Sample input

5
12 -4 8 12 0

Sample output

true

Sign in to run or submit a solution in C++, Java or Python.