Skip to content

Instantly share code, notes, and snippets.

@dit7ya
Created January 6, 2019 14:40
Show Gist options
  • Save dit7ya/b07bea313e7bee5894e20445372f1efa to your computer and use it in GitHub Desktop.
Save dit7ya/b07bea313e7bee5894e20445372f1efa to your computer and use it in GitHub Desktop.
CodeSignal First Interview Problem
import numpy as np
def firstDuplicate(a):
num = -1
seen = np.zeros(len(a))
for x in a:
if seen[x - 1] == 0:
seen[x - 1] +=1
else:
num = x
break
return num
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment