223. Rectangle Area
来源:互联网 发布:苏格兰炸蛋 知乎 编辑:程序博客网 时间:2024/06/03 21:00
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
"""
overlap = max(min(C,G)-max(A,E), 0)*max(min(D,H)-max(B,F), 0)
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
"""
overlap = max(min(C,G)-max(A,E), 0)*max(min(D,H)-max(B,F), 0)
return (A-C)*(B-D) + (E-G)*(F-H) - overlap
http://bookshadow.com/weblog/2015/06/08/leetcode-rectangle-area/
阅读全文
0 0
- 223. Rectangle Area
- [leetcode] 223.Rectangle Area
- [leetcode] 223. Rectangle Area
- 223. Rectangle Area LeetCode
- #leetcode# 223. Rectangle Area
- 223. Rectangle Area
- leetcode 223. Rectangle Area
- 223. Rectangle Area
- LeetCode--223. Rectangle Area
- 223. Rectangle Area
- LeetCode *** 223. Rectangle Area
- LeetCode 223. Rectangle Area
- leetcode-223. Rectangle Area
- 223. Rectangle Area
- 223. Rectangle Area
- LeetCode-223.Rectangle Area
- 223.[Leetcode]Rectangle Area
- 223. Rectangle Area
- [LeetCode] 119. Pascal's Triangle II
- samson-wang/dcgan.caffe
- codeforces 755c 并查集+迷之题意....
- leetcode题解-160. Intersection of Two Linked Lists
- c#中的多态
- 223. Rectangle Area
- js:根据闰年的判断条件,利用if循环判断闰年
- 倒计时一分十秒
- Android开发中算法积累小结
- NYOJ:8-一种排序
- 天才黑客打脸乔布斯玩转索尼叫板特斯拉!
- java实现邮箱找密码
- jsp中<%@ %> 与<% %> 与<%! %>
- 用canvas实现一个简易的涂鸦画板