Return Coordinates of Rectangle

  • 0

    Given two rectangle return coordinates of overlapping rectangle if any

  • 0

    @reemak Welcome to the new Discuss! Could you please add at least one example, and also add the company to the tags? Please see here for more information.

  • 0

    I believe that we can find the coordinates of two overlapping rectangle in the following way:

    Rectangle overlapArrea(Rectangle rc1, Rectangle rc2)  {
        Rectangle res  =  new Rectangle();
        res.lpt  =  new Point(Math.max(rc1.lpt.x, rc2.lpt.x), Math.max(rc1.lpt.y, rc2.lpt.y));
        res.bpt  =  new Point(Math.min(rc1.bpt.x, rc2.bpt.x), Math.min(rc1.bpt.y, rc2.bpt.y));   
        return res;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.