summaryrefslogtreecommitdiff
path: root/progs/test.py
blob: 718885d11818832d66b8eb3938ba028c2cf765a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import math
from re import f4, r3

from abs import *


def find_first_duplicate(nums, x):
    num_set = set()
    no_duplicate = -1

    for i in range(len(nums)):
        if nums[i] in num_set:
            return nums[i]
        else:
            num_set.add(nums[i])

    return no_duplicate