【leetcode❤python】 223. Rectangle Area

#-*- coding: UTF-8 -*-
#先判断是否有重叠
class Solution(object):
    def computeArea(self, A, B, C, D, E, F, G, H):
        """
        :type A: int
        :type B: int
        :type C: int
        :type D: int
        :type E: int
        :type F: int
        :type G: int
        :type H: int
        :rtype: int
        """
        if C<=E or B>=H or A>=G or D<=F:
            return (C-A)*(D-B)+(G-E)*(H-F)
        width=min(C,G)-max(E,A)
        height=min(D,H)-max(B,F)
        
        return (C-A)*(D-B)+(G-E)*(H-F)-width*height

上一篇:CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享


下一篇:CentOS 6.8编译安装httpd2.2.31+MySQL5.6.31+PHP5.3.27