题目:原题链接(中等)
标签:数组
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
---|---|---|---|
Ans 1 (Python) | O ( H l o g H + V l o g V ) O(HlogH+VlogV) O(HlogH+VlogV) | O ( l o g H + l o g V ) O(logH+logV) O(logH+logV) | 120ms (77.67%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
_MOD = 10 ** 9 + 7
def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
width, height = 0, 0
horizontalCuts.sort()
horizontalCuts.append(h)
last = 0
for n in horizontalCuts:
height = max(height, n - last)
last = n
verticalCuts.sort()
verticalCuts.append(w)
last = 0
for n in verticalCuts:
width = max(width, n - last)
last = n
return width * height % self._MOD
最后
以上就是纯情篮球最近收集整理的关于LeetCode题解(1465):切割后面积最大的蛋糕(Python)的全部内容,更多相关LeetCode题解(1465):切割后面积最大内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复