Question d’entretien chez Microsoft

Write a function that return N-th distinct element from array. example: N=2 Array=[a,a,b,c,d,c,e] Answer = d because a and c is not distinct in array and omitted

Réponse à la question d'entretien

Utilisateur anonyme

2 mars 2022

I used dictionary to store elements as a key and number of appearance as a value then in next run over the array check the value in this dictionary and if it's 1 then increase the counter till N