Interview patterns - technical interview questions logo
 

Overlapping rectangles

by Alex 25. October 2009 10:07

My wife is interviewing for the SDET/STE position now, so I got the access to the stream of new interview questions.

With the economy going down job market got really competitive and I was not surprised to see what STE/SDET interviews often start consist of many white board coding questions and algorithmic problems. I will keep sharing her experience as she goes through the obstacles of the job search.

She just started her search, so she is mainly going through the screening process and interviews with the recruiters. As I see, screening process didn’t change that much and she getting mostly questions about her experience and educations or pretty basic questions such as “What is .NET?”, “What is black box testing?”, “How would you select a row from DB in SQL?”. 

Very few (if any) companies did deep technical screening and only Volt  asked her to complete online SQL evaluation via Prove It! service.

On site screening is a different story; all interviews are very technical with a lot of coding on white boards with same problems I would expect to see on the developers interviews.

As one of the examples here is the “Rectangle overlap problem”

There are two rectangles defined by two points LR {x,y} and UL {x,y}.  LR is lower right point and UL is upper left point as show on the image below.

Rectangles Overlap

Rectangles are always aligned with X,Y axis as show on the picture. The task is to write a function which would check if two given rectangles overlap or not.

bool  IsOverlap(Rect R1, Rect R2),  where Rect defined as following


struct Rect
{
public Point UL;
public point LR;
}   

Initially it looks like very hard problem and from looking on many possible variations it might look even harder:

Rectangles Variations

The key to notice is that the actual test needed is to check if any of Rect1 corners are inside Rect2 and vice versa. In other words those two rectangle will not overlap if rectangle Rect1 is above Rect2 or below Rect2 or left from Rect2 or right from Rect2.  If any of those conditions are true rectangle don’t overlap… Just four checks !

bool  IsOverlap(Rect R1, Rect R2)

{

return ((R1.LR.y <= R2.UL.y)

(R1.LR.x >= R2.UL.x) &&

(R1.UL.x <= R2.LR.x) &&

(R1.UL.y  >= R2.LR.y) &&

)}

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

C# | Phone Interview | On-Site Interview Strategies


Comments




All material copyright © North Pacific Technology Group, LLC. All rights are reserved. No part of any material on this web site may be reproduced, or stored in a database or retrieval system, distributed, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission. Terms of use.

Powered by BlogEngine.NET 1.4.5.0

Job Search

what
job title, keywords
where
city, state, zip
jobs by job search