LeetCode \"Maximal Rectangle\"

倖福魔咒の 提交于 2020-02-24 04:58:13

My intuition is flood-fill the BFS solution, which is O(n^4); and then I figured out a DP solution which is O(n^4)..

So I googled some hints: it can be built upon another LeetCode problem: Largest Rectangle in Histogram. With proper pre-calculation, we can make a O(n^3) solution. What's more, we can start from bottom-right to upper-left, and then make sure each '1' cell is visited only once - that's O(n^2).

http://yucoding.blogspot.com/2013/01/incomplete-leetcode-question-47-maximal.html

And as always, there's such a great solution: https://leetcode.com/discuss/20240/share-my-dp-solution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!