Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d84e6dc

Browse files
Create Solution.py
1 parent e671351 commit d84e6dc

File tree

1 file changed

+10
-0
lines changed
  • Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
3+
horizontalCuts.sort()
4+
verticalCuts.sort()
5+
maxh, maxv = max(horizontalCuts[0], h - horizontalCuts[-1]), max(verticalCuts[0], w - verticalCuts[-1])
6+
for i in range(len(horizontalCuts)):
7+
maxh = max(maxh, horizontalCuts[i] - horizontalCuts[i-1])
8+
for i in range(len(verticalCuts)):
9+
maxv = max(maxv, verticalCuts[i] - verticalCuts[i-1])
10+
return (maxh * maxv) % (10**9 + 7)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /