## [切割后面積最大的蛋糕](https://leetcode-cn.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/)
#### 思路
這道題首先意思是,橫著切幾刀,豎著切幾刀。然后形成了若干個區域,問這些區域中最大的面積是多少。
* 要想面積最大,也就是橫向最大的間隔和縱向最大的間隔所形成的的區域
* 考慮邊界,切割線和邊界也能形成間隔
* 那么我們要先排序,因為排序之后我們才知道,哪幾條切割線是和邊界形成區域的
* 最后,結果對對`$ 10^9 + 7 $`取余取余
AC!
#### 代碼
python3
```
class Solution:
def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
horizontalCuts = sorted(horizontalCuts)
verticalCuts = sorted(verticalCuts)
hs = horizontalCuts[0]
vs = verticalCuts[0]
for l in range(1, len(horizontalCuts)):
hs = max(hs, horizontalCuts[l] - horizontalCuts[l-1])
for v in range(1, len(verticalCuts)):
vs = max(vs, verticalCuts[v] - verticalCuts[v-1])
hs = max(hs, h - horizontalCuts[-1])
vs = max(vs, w - verticalCuts[-1])
return (hs % (10 ** 9 + 7) * vs % (10 ** 9 + 7)) % (10 ** 9 + 7)
```
- 目錄
- excel-sheet-column-number
- divide-two-integers
- house-robber
- fraction-to-recurring-decimal
- profile
- kids-with-the-greatest-number-of-candies
- qiu-12n-lcof
- new-21-game
- product-of-array-except-self
- minimum-depth-of-binary-tree
- univalued-binary-tree
- shun-shi-zhen-da-yin-ju-zhen-lcof
- permutations
- satisfiability-of-equality-equations
- word-ladder-ii
- ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof
- palindrome-number
- network-delay-time
- daily-temperatures
- longest-common-prefix
- sum-of-mutated-array-closest-to-target
- 周賽專題
- make-two-arrays-equal-by-reversing-sub-arrays
- check-if-a-string-contains-all-binary-codes-of-size-k
- course-schedule-iv
- cherry-pickup-ii
- maximum-product-of-two-elements-in-an-array
- maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
- reorder-routes-to-make-all-paths-lead-to-the-city-zero
- probability-of-a-two-boxes-having-the-same-number-of-distinct-balls
- shuffle-the-array
- the-k-strongest-values-in-an-array
- design-browser-history
- paint-house-iii
- final-prices-with-a-special-discount-in-a-shop