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
Anonymous
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
Check out your Company Bowl for anonymous work chats.