223. Rectangle Area
2016-12-02 本文已影响0人
我是你的果果呀
Find the total area covered by two rectilinear rectangles in a 2Dplane.
Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.
Assume that the total area is never beyond the maximum possible value of int.
求两个矩形的总面积, 关键点在于求矩形是否相交, 以及交集的面积。
判断是否相交: 1的左x点和2的右x点, 1 的右x点和2的左x点, 1的下y点和2的上y点, 1的上y点和2的下y点比较。