summaryrefslogtreecommitdiff
path: root/progs/a385.py
blob: eed88cc73901a7f96e0d39c36eb05c797debeb3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
def find_first_duplicate(nums):
    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