Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
07_ReverseInteger.py Delete directory Week01, move solutions in Week01 to maching Tags Oct 20, 2015
09_PalindromeNumber.cpp add 09 cpp and update some py May 6, 2016
09_PalindromeNumber.py add 09 cpp and update some py May 6, 2016
12_IntegertoRoman.py Delete directory Week02, rewrite some solutions in Week02 and move th… Oct 21, 2015
13_RomantoInteger.py Delete directory Week02, rewrite some solutions in Week02 and move th… Oct 21, 2015
166_FractionToRecurringDecimal.py add 168, 169, 166, 171 Dec 7, 2015
168_ExcelSheetColumnTitle.py add 168, 169, 166, 171 Dec 7, 2015
171_ExcelSheetColumnNumber.py add 168, 169, 166, 171 Dec 7, 2015
172_FactorialTrailingZeroes.py 172,173,174,179 Dec 8, 2015
179_LargestNumber.py 172,173,174,179 Dec 8, 2015
202_HappyNumber.py add 201, 202 Dec 20, 2015
204_CountPrimes.py Week 16 Dec 23, 2015
223_RectangleArea.cpp add math readme and 223 Apr 12, 2016
223_RectangleArea.py add 216, 217, 219, 220, 221, 222, 223 Dec 30, 2015
233_NumberOfDigitOne.cpp update 233 Apr 28, 2016
233_NumberOfDigitOne.py update 233 Apr 28, 2016
238_ProductOfArrayExceptSelf.py add 236, 237, 238, 239 Jan 21, 2016
258_AddDigits.py add 242, 258 Jan 22, 2016
263_UglyNumber.cpp update 264 UglyNumber cpp Apr 15, 2016
263_UglyNumber.py update 264 UglyNumber cpp Apr 15, 2016
273_IntegerToEnglishWords.py add 268, 273, 274, 275 Jan 25, 2016
292_NimGame.py add 289, 290, 292 Jan 28, 2016
319_BulbSwitcher.py add 318, 319 Feb 24, 2016
326_PowerOfThree.py add 326, 328 Feb 19, 2016
335_SelfCrossing.py add 335 Apr 5, 2016
343_IntegerBreak.cpp add 343. Integer Break Jul 4, 2016
343_IntegerBreak.py add 343. Integer Break Jul 4, 2016
43_MultiplyStrings.cpp update 42, 43, 44, 45 Jul 26, 2016
43_MultiplyStrings.py update 42, 43, 44, 45 Jul 26, 2016
48_RotateImage.cpp add 48 RotateImage Jun 12, 2016
48_RotateImage.py add 48 RotateImage Jun 12, 2016
50_Pow.cpp add 50 Pow(x, n) Jun 26, 2016
50_Pow.py add 50 Pow(x, n) Jun 26, 2016
60_PermutationSequence.cpp add Permutation Sequence Jun 28, 2016
60_PermutationSequence.py add Permutation Sequence Jun 28, 2016
66_PlusOne.py links to the source code in README.md Nov 4, 2015
README.md fix picture url in readme Apr 12, 2016

README.md

题目

223 Rectangle Area

计算平面坐标系中两个矩形覆盖的面积。注意两个矩形有可能相交,相交部分面积只能算一次,其中给出了每个矩形的左下角和右上角的坐标。

下图为矩形的可能情况:

解决问题关键在于假设矩形相交,然后找出重合的小矩形的左下角坐标和右上角坐标,判断这两个坐标是否能够构成矩形。

// 假设两个矩形相交,重合矩形的坐标如下
int left = max(A, E);
int bottom = max(B, F);
int right = min(C, G);
int top = min(D, H);

矩形相交的条件为 left < right && bottom < top