Pregunta de entrevista de 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

Respuesta de la entrevista

Anónimo

2 mar 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