Amazon Interview Question for SDE-2s

Team: Transportation Team
Country: India
Interview Type: In-Person

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

Okay lets break the problem down. Begin with calcuation
1. Visit one site (1 URL)
2. Go through all of its images, mark them V Good - Poor and calculate some sort of average. We will need some scale of marking. So lets take: V Good = 4, Good = 3, Avg = 2, Poor = 1
S = Total score of the URL, N = Total number of images on the URL

S = 0; N = 0;
for (i = next image in URL; i < Last image in URL; i++)
{
//take next image say I
S = S + ScoreOf(I);
N++;
}

Avg_Score_For_URL = S / N;

3. Now to store the score of a website. Use a hashtable/ STP map which takes key-val pairs.
So key = URL, value = Avg_Score_For_URL. This will also serve as a check for already visited URL's. Before visiting a URL check if its entry already exists in the hashtable.

This would be a very basic solution.

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

This is a standard graph traversal problem. In that Each URL is a node and set of images on each node is data on which certain processing is to be done.
We can use BFS or DFS for traversal of the URL. We can define size of the image as a metric to judge quality of image. So that more the size of the image better it would be. Now, make few buckets of size and assign an integer to them. For example: image of size range 4-6 mb would be average so number 2 could be assigned. Image with size less than 10 kb would below good so number 0 can assigned.

After traversing through all the images, we can get average value of the image quality.

I have provided just a basic idea. Otherwise there could be n number of ways in which we could get image quality.

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

This is a standard graph traversal problem. In that Each URL is a node and set of images on each node is data on which certain processing is to be done.
We can use BFS or DFS for traversal of the URL. We can define size of the image as a metric to judge quality of image. So that more the size of the image better it would be. Now, make few buckets of size and assign an integer to them. For example: image of size range 4-6 mb would be average so number 2 could be assigned. Image with size less than 10 kb would below good so number 0 can assigned.

After traversing through all the images, we can get average value of the image quality.

I have provided just a basic idea. Otherwise there could be n number of ways in which we could get image quality.

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.

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.