JPMorganChase Interview Question

How do find if a point is inside a rectangle.

Interview Answers

Anonymous

Sep 11, 2018

for the given point (x,y) and points for the rectangles (x1,y1) (x2,y1) (x1,y2) (x2,y2) check if x lies between x1 and x2 and y lies between y1 and y2

Anonymous

Jul 18, 2017

Logically, if you calculate the distance of this point from each of the four corners of the rectangle one by one ... none of them should be greater than the diagonal of the rectangle.