由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请问一道题--给一个正方形矩阵,每个元素要么黑色要么白色,请找出最大的纯色子矩阵
相关主题
Google interview questionMaximal Rectangle O(mn) 解法 非 histogram
关于矩阵中找矩形和正方形汇总请教OJ里面的Maximal Rectangle
google 面试题G家intern电面
总结一道题问个老算法题
histogram问题Maximal Rectangle TLE是指代码正确,但不是最优吗?
leetcode一道题O(NlogN) largest rectangle in histogram
Modified Maximal Rectangle problem from Leetcode那个常见的histogram max rectangle 问题
再问Maximal Rectangle的N^2解法又想起一道google题目
相关话题的讨论汇总
话题: 矩阵话题: problem话题: maximal话题: solution话题: largest
进入JobHunting版参与讨论
1 (共1页)
k********w
发帖数: 1
1
一个矩阵比如是n*n的, 然后每个元素要么黑色要么白色,可以用一个值为0 或者1的
二位整数数组来模拟。 要求找出纯色的最大的正方形子矩阵,比如全是一片的0或者1.
想了很久没有什么特别好的方案,
请大家指教!
a****n
发帖数: 1887
2
DP
b********h
发帖数: 119
3
This is the maximal rectangle problem:
http://www.drdobbs.com/184410529
In particular, the last solution provided in the article is the application
of the solution of another interesting problem: Largest rectangle in a
Histogram (problem H in the following link).
http://www.informatik.uni-ulm.de/acm/Locals/2003/html/judge.html
Both of them have many solutions that are of different complexity.
a****n
发帖数: 1887
4
正方形和矩形解法不一样

application

【在 b********h 的大作中提到】
: This is the maximal rectangle problem:
: http://www.drdobbs.com/184410529
: In particular, the last solution provided in the article is the application
: of the solution of another interesting problem: Largest rectangle in a
: Histogram (problem H in the following link).
: http://www.informatik.uni-ulm.de/acm/Locals/2003/html/judge.html
: Both of them have many solutions that are of different complexity.

b********h
发帖数: 119
5
True. I misread the problem. I think the correct solution is DP with the
following recurrence:
S[i][j] = min{ S[i-1][j], S[i][j-1], S[i-1][j-1] } + 1, where S[i][j] is the maximal
size of the square with its bottom right at (i,j) and (i,j) contains the
value you are looking for (either 0 or 1). The largest S[i][j] is the answer
.
l**********3
发帖数: 161
6
S[i,j]怎么初始化?
递归公式不是很懂,能不能举个例子解释一下?谢谢!

the maximal
answer

【在 b********h 的大作中提到】
: True. I misread the problem. I think the correct solution is DP with the
: following recurrence:
: S[i][j] = min{ S[i-1][j], S[i][j-1], S[i-1][j-1] } + 1, where S[i][j] is the maximal
: size of the square with its bottom right at (i,j) and (i,j) contains the
: value you are looking for (either 0 or 1). The largest S[i][j] is the answer
: .

1 (共1页)
进入JobHunting版参与讨论
相关主题
又想起一道google题目histogram问题
maximum rectangle in histogram 到底是个什么问题?leetcode一道题
challenge: 找bugModified Maximal Rectangle problem from Leetcode
google的一道题求解再问Maximal Rectangle的N^2解法
Google interview questionMaximal Rectangle O(mn) 解法 非 histogram
关于矩阵中找矩形和正方形汇总请教OJ里面的Maximal Rectangle
google 面试题G家intern电面
总结一道题问个老算法题
相关话题的讨论汇总
话题: 矩阵话题: problem话题: maximal话题: solution话题: largest