Detect whether two rectangles have common area or not -- Amazon