LeetCode 223. Rectangle Area
来源:互联网 发布:2016软件评测师真题 编辑:程序博客网 时间:2024/04/29 20:34
223. Rectangle Area
My Submissions QuestionEditorial Solution
Total Accepted: 34834 Total Submissions: 117121 Difficulty: Easy
Find the total area covered by two rectilinear rectangles in a 2D plane.
Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.
Rectangle Area
Assume that the total area is never beyond the maximum possible value of int.
class Solution {public: int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int maxae = A > E ? A : E; int mincg = C > G ? G : C; int maxfb = F > B ? F : B; int minhd = H > D ? D : H; int overlap; if(maxae >= mincg || maxfb >= minhd) overlap = 0; else overlap = (mincg - maxae) * (minhd - maxfb); return (C - A) * (D - B) + (G - E) * (H - F) - overlap; }};
0 0
- [leetcode] 223.Rectangle Area
- [leetcode] 223. Rectangle Area
- 223. Rectangle Area LeetCode
- #leetcode# 223. Rectangle Area
- leetcode 223. Rectangle Area
- LeetCode--223. Rectangle Area
- LeetCode *** 223. Rectangle Area
- LeetCode 223. Rectangle Area
- leetcode-223. Rectangle Area
- LeetCode-223.Rectangle Area
- 223.[Leetcode]Rectangle Area
- leetcode 223. Rectangle Area
- 【leetcode】223. Rectangle Area
- [Leetcode]223. Rectangle Area
- LeetCode - 223. Rectangle Area
- LeetCode 223. Rectangle Area
- LeetCode 223. Rectangle Area
- LeetCode 223. Rectangle Area
- 判断滚动条到底部的JS代码
- LeetCode 20. Valid Parentheses
- 算法--列(java实现)
- LeetCode 299. Bulls and Cows
- LeetCode 205. Isomorphic Strings
- LeetCode 223. Rectangle Area
- Java字符串工具类(未测试)
- LeetCode 219. Contains Duplicate II
- java lisi乱序、排序
- LeetCode 88. Merge Sorted Array
- LeetCode 160. Intersection of Two Linked Lists
- LeetCode 36. Valid Sudoku
- java中常用的时间处理类TimeUtil
- LeetCode 112. Path Sum