Algorithms and Data Structures/Coding Practices

AlgoExpert First Duplicate Value

brightlightkim 2022. 7. 22. 09:24

def firstDuplicateValue(array):
    compArray = []
    for num in array:
        if num in compArray:
            return num
        compArray.append(num)
    return -1

'Algorithms and Data Structures > Coding Practices' 카테고리의 다른 글

AlgoExpert Merge Overlapping Intervals  (0) 2022.07.22
AlgoExpert Array of Products  (0) 2022.07.22
AlgoExpert Monotonic Array  (0) 2022.07.21
AlgoExpert Move Element to End  (0) 2022.07.20
Kattis Above Average  (0) 2022.07.20