class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
long total = max((C-A),0) * max((D-B),0) + max((G-E),0) * max((H-F),0) ;
long comm;
if(min(G,C) < max(E,A) || min(H,D) < max(F,B) ) //防止越界
comm = 0;
else
comm = max(0,min(G,C)-max(E,A)) * max(0,min(H,D)-max(F,B)) ; return total-comm;
} };

  原题在此处  https://leetcode.com/problems/rectangle-area/

Rectangle Area的更多相关文章

  1. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

  2. [leetcode] Rectangle Area

    Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...

  3. 【leetcode】Contains Duplicate & Rectangle Area(easy)

    Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your funct ...

  4. [LeetCode] 850. Rectangle Area II 矩形面积之二

    We are given a list of (axis-aligned) rectangles.  Each rectangle[i] = [x1, y1, x2, y2] , where (x1, ...

  5. [LeetCode] 223. Rectangle Area 矩形面积

    Find the total area covered by two rectilinearrectangles in a 2D plane. Each rectangle is defined by ...

  6. LeetCode 223. 矩形面积(Rectangle Area)

    223. 矩形面积 223. Rectangle Area 题目描述 在二维平面上计算出两个由直线构成的矩形重叠后形成的总面积. 每个矩形由其左下顶点和右上顶点坐标表示,如图所示. LeetCode2 ...

  7. 【刷题-LeetCode】223. Rectangle Area

    Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...

  8. Java for LeetCode 223 Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

  9. (easy)LeetCode 223.Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

  10. leetcode:Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

随机推荐

  1. 安卓中級教程(5):ScrollView與refreshable之間的設置

    設置向下拉動更新. package com.mycompany.Scroll_test; import android.app.*; import android.os.*; import andro ...

  2. User interface

    Styles and Themes value/style <style name="CodeFont" parent="@android:style/TextAp ...

  3. 关于 apue.h 的使用方法

    unix中有很多地方使用到apue.h  .apue.h是作者自己写的一个头文件,这个文件怎么用,晚上有很多方法,但是经过尝试大多不好用. 经过本人尝试,可以把src.3e.tar.gz 的代码解压到 ...

  4. Educational Codeforces Round 6 E dfs序+线段树

    题意:给出一颗有根树的构造和一开始每个点的颜色 有两种操作 1 : 给定点的子树群体涂色 2 : 求给定点的子树中有多少种颜色 比较容易想到dfs序+线段树去做 dfs序是很久以前看的bilibili ...

  5. kafka综合介绍

    设计目标 高吞吐率.即使在非常廉价的商用机器上也能做到单机支持每秒100K条以上消息的传输. 支持Kafka Server间的消息分区,及分布式消费,同时保证每个Partition内的消息顺序传输 同 ...

  6. Mysql5.6.17 zip版本安装

    1.把 mysql解压到自定义 D:\mysql-5.6.17-W642.我的电脑--属性--高级--环境变量--系统变量--新建系统环境变量       变量名:MYSQL_HOME       变 ...

  7. 转:HAR(HTTP Archive)规范

    HAR(HTTP Archive),是一个用来储存HTTP请求/响应信息的通用文件格式,基于JSON.这个格式的出现可以使HTTP监测工具以一种通用的格式导出所收集的数据,这些数据可以被其他支持HAR ...

  8. css3图片翻转

    <!DOCTYPE> <html lang="en"> <head> <meta http-equiv="Content-Typ ...

  9. php页面如何增加下载软件功能

    php <?php $array = parse_ini_file("sample.ini"); ?> <a id="btnDownloadFull&q ...

  10. EasyUI分页

    $("#tanModelBox1").css("display","none"); $('#dg').datagrid({ fitColum ...