Pergunta de entrevista da empresa Bloomberg

Given a vector of integer elements. Remove the duplicates. Do not change the order of elements.

Respostas da entrevista

Sigiloso

31 de jul. de 2017

If you are using Java, LinkedHashSet class can be used to achieve the same

1

Sigiloso

19 de abr. de 2018

Just make a hashmap and check if the key exists and if it does delete the element and if it doesnt add it to the hashmap as a key with a boolean true

Sigiloso

6 de jul. de 2017

I did it wrong. I realized later you can iterate through the vector once and store in a map, if element is present or not. Iterate through the vector again and each time check if the element is present as a key in the map. First encounter, delete the key val pair from the map. So that the next time same element appears in the vector, it would not be found in the map, so remove the element from the vector and shift all the subsequent vector elements backwards.