Amazon Interview Question for SDE1s


Country: India
Interview Type: Written Test




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

(x1, y1)------------------
| |
| .(x,y) |
| |
| |
------------------------x2, y2

for a rectangle in a list of rectangles
     if ((x > x1 && x < x2) && (y > y1 && y < y2))
	      temp_area = (x2 - x1) * (y2 - y1);
		  if (temp_area < area) 
		  area = temp_area;

- RanjeetSih July 06, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

So, in essence, find all the rectangles enclosing the point. The find the rectangle with minimum area among those rectangles.

- puneet.sohi July 06, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

shouldn't it be y<=y1 && y >= y2 and putting equal to signs would be better

- liju.leelives July 08, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

What about intersections between rectangles forming smaller rectangles?

- Anonymous December 01, 2015 | Flag


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