Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
I think a simple Array and a int location would be good
Whenever a new item come in, location++;
if location==size;location =0;
Plain arrays wont be a good choice.
Try a circular queue instead with o(1) insertion and deletion
tksrules, why arrays are not a good choice?
According to the question, arrays are the best one as provide random access and limited storage.
we use array implementation but along with the array we will have an bit array of size size which is useful for deletion, we does not delete any element we just overwrite it, once delete command is executed for an element we set its' bit to zero.
- sonesh January 23, 2013and it is easy to implement array in circular faction as required by question.