Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
2
of 2 vote

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.
and it is easy to implement array in circular faction as required by question.

- sonesh January 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think a simple Array and a int location would be good
Whenever a new item come in, location++;
if location==size;location =0;

- Beserk January 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Plain arrays wont be a good choice.

Try a circular queue instead with o(1) insertion and deletion

- focker123 January 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

But circular queue won't support random access..

- Beserk January 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

tksrules, why arrays are not a good choice?
According to the question, arrays are the best one as provide random access and limited storage.

- DashDash January 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

we can implement circuler queue with array to resolve this

- Raj January 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

We can use circuler queue to store the elements .for gng to particulr element in o(1) we have to use hash set .

- Raj January 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Array for storage of data. With index i pointing to index to be filled for new data. i will be incremented by formula i = (i+1)%SIZE_OF_ARRAY
As well as HASHTABLE<data,index> for constant time access to data.

- krb January 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class cache
{
Object[] elements;
int max;
int count;

cache(int i)
{
elements = new Object[i];
this.max=i;
}
void add(object obj)
{
if(count==max)
{
count=0;
}
element[count]=obj;
count++;
}

Object get(int i)
{
return element[i];
}
}

- Anonymous January 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we can use cirsular linkedlist [This develops circular cache]+ Hashset [This provides random acess to cache]

- Circular LL + HS January 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hashmap. With the position/index being the key and the data being the value.
ex {(1,3),(2,6)} ; here data 3 is inserted first , 6 second and so on. Just check the key in the hash map.

- Anonymous February 13, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More