223. Rectangle Area

忘是亡心i 2023-06-03 15:55 128阅读 0赞
  1. class Solution {
  2. public:
  3. int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
  4. int left = max(A,E), right = max(min(C,G), left);
  5. int bottom = max(B,F), top = max(min(D,H), bottom);
  6. return (C - A) * (D - B) - (right - left) * (top - bottom) + (G - E) * (H - F);
  7. }
  8. };

转载于:https://www.cnblogs.com/ymjyqsx/p/11324698.html

发表评论

表情:
评论列表 (有 0 条评论,128人围观)

还没有评论,来说两句吧...

相关阅读