[leetcode]Largest Rectangle in Histogram...
分类:
其他好文 时间:
2014-10-20 11:55:19
阅读次数:
156
先来介绍几个画矩形的函数:DrawFocusRect():画一个焦点矩形;Rectangle():用当前选定的画笔描绘矩形,并用当前选定的画刷填充;DrawEdge():用指定的样式描绘一个矩形的边框;RoundRect():用当前选定的画笔画一个圆角矩形,并用当前选定的画刷填充。今天用的是Draw...
题目大意:给你一个直方图,告诉你各个条形矩形的高度,求基线对齐构成的矩形中面积
最大的矩形的面积对于每一个矩形。面积 = h[i]*(j-k+1),其中j,k是左右边界,h[i]是矩形
的高。并且对于j <= x <= k,h[i] <= h[x]。
本题中,找到左右边界j,k是关键。
利用动态规划的方法,对于位置i,如果左边条形矩形的高度大于它本身,那么左边的左边
界一定也满足位置i的左边界。同理如果右边条形矩形的高度大于它本身,那么右边的右边
界也一定满足位置i的右边界。迭代循环下去。直到找到i的左右边...
分类:
其他好文 时间:
2014-10-18 11:16:38
阅读次数:
173
Problem Description
Given an N * M matrix with each entry equal to 0 or 1. We can find some rectangles in the matrix whose entries are all 1, and we define the maximum area of such rectangle as this ...
分类:
移动开发 时间:
2014-10-17 23:26:50
阅读次数:
264
Problem Description
A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figu...
分类:
其他好文 时间:
2014-10-17 23:26:46
阅读次数:
426
先搞定这题。ZOJ1985 Largest Rectangle in a Histogram再做这题。先枚举第二个矩形对第一个矩形的偏移量(x,y),再进行2维DP,复杂度为O(n^2 *n^2),即O(n^4).#include using namespace std;const int maxn...
分类:
其他好文 时间:
2014-10-17 00:07:53
阅读次数:
405
Largest Rectangle in Histogram
Total Accepted: 18582 Total
Submissions: 86792My Submissions
Given n non-negative integers representing the histogram's bar height where the width of each b...
分类:
其他好文 时间:
2014-10-14 16:38:09
阅读次数:
154
[leetcode]Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area....
分类:
其他好文 时间:
2014-10-14 13:49:48
阅读次数:
148
code: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 class Solution { 8 public: 9 int largestRectangleArea(vector &he...
分类:
其他好文 时间:
2014-10-13 21:25:07
阅读次数:
221
1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 class Solution { 8 public: 9 int largestRectangleArea(vector &height)...
分类:
其他好文 时间:
2014-10-12 23:59:48
阅读次数:
173