first_positions = zeroes (26)
nb_occs = zeroes (26)
for in range (0,len(s)):
index = s[i] - '0'
if nb_occs[index] == 0
first_positions[index] = i
nb_occs[index] += 1
then simply iterate on nb_occs and return minimum corresponding value in first_positions where nb_occs == 1
Aucun commentaire:
Enregistrer un commentaire