FirstDuplicate Finder
Review


Adhere PEP8


functions and variable should be snake_case
Avoid multiple statements on one line


if len(a) == 0: return -1 


Indentation matters, and an indentation of 4 spaces is the standard

You don't need all these guard clauses


if len(a) == 0: return -1
if len(a) == 1: return -1
if len(a) == 2 and a[0] == a[1]: return a[0]


The else: does nothing here, only adds an extra indentation level
When you need both the index and the item it is better to enumerate!


for x in (range(len(b)-1)):


For timing, see the Time complexity for python

You use some expensive operations while this can be done is a single loop


.sort() O(n log n)
.index() is O(n)



Note: Look for example at vnp's solution