#C5239. Find the First Repeated Element

    ID: 48866 Type: Default 1000ms 256MiB

Find the First Repeated Element

Find the First Repeated Element

You are given a list of integers. Your task is to find the first element that appears at least twice. In other words, traverse the list from left to right and report the first number for which a previous occurrence exists. If no such element exists, output No repetition.

The intended solution should operate in \( \mathcal{O}(n) \) time complexity on average.

Example:

  • Input: 5 and [1, 2, 3, 4, 2] produces output: 2
  • Input: 4 and [4, 1, 3, 2] produces output: No repetition

inputFormat

The input is read from standard input (stdin) with the following format:

  1. The first line contains a single integer \( n \) representing the number of elements in the list.
  2. The second line contains \( n \) space-separated integers which are the elements of the list.

outputFormat

Print the first repeated element to standard output (stdout). If there is no repetition in the list, output No repetition.

## sample
4
4 1 3 2
No repetition