Pergunta de entrevista da empresa A9.com

technical Q: Solve problem - Inverted index Given a query term “red shirt” red = {1, 3, 5, 8, 9} shirt = {1, 2, 4, 6, 7, 9} you should return a list of {1, 9} because the item is red, and is also a shirt. Try to do it in the shortest runtime possible without using extra memory.

Resposta da entrevista

Sigiloso

17 de mar. de 2017

using two pointers i> if numbers match then copy it to return list, increment both the pointers ii> if numbers do not match then increment pointer of the list whose number is smaller in current comparision.

1