Pergunta de entrevista da empresa Imperva

design and implement a data structure that does this command : insert in O(1) get in O(1) and res tet in O(1)

Resposta da entrevista

Sigiloso

9 de mar. de 2021

I used two arrays and a version counter, array 1 is the data and array 2 was the update version, insert and get are easy in O(1) this is an array. but when you insert you put the array 2 value to be the version counter and when you get you to check if the version couter is equal to the array 2 value if not this is not valid data. in order to reset you just increment the version counter by one