当前位置: 首页 > news >正文

重庆装修公司网站建设什么推广平台好

重庆装修公司网站建设,什么推广平台好,北京有哪些大型互联网公司,山西网络公司靠谱题目 请在一个由0、1组成的矩阵中找出最大的只包含1的矩形并输出它的面积。例如,在图6.6的矩阵中,最大的只包含1的矩阵如阴影部分所示,它的面积是6。 分析 直方图是由排列在同一基线上的相邻柱子组成的图形。由于题目要求矩形中只包含数字…

题目

请在一个由0、1组成的矩阵中找出最大的只包含1的矩形并输出它的面积。例如,在图6.6的矩阵中,最大的只包含1的矩阵如阴影部分所示,它的面积是6。
在这里插入图片描述

分析

直方图是由排列在同一基线上的相邻柱子组成的图形。由于题目要求矩形中只包含数字1,因此将矩阵中上下相邻的值为1的格子看成直方图中的柱子。如果分别以图6.6中的矩阵的每行为基线,就可以得到4个由数字1的格子组成的直方图,如图6.7所示。
在这里插入图片描述

在将矩阵转换成多个直方图之后,就可以计算并比较每个直方图的最大矩形面积,所有直方图中的最大矩形也是整个矩阵中的最大矩形。例如,图6.7(c)的直方图中的最大矩形(阴影部分)也是图6.6中矩阵的最大矩形。

public class Test {public static void main(String[] args) {char[][] matrix = {{'1', '0', '1', '0', '0' },{'0', '0', '1', '1', '1' },{'1', '1', '1', '1', '1' },{'1', '0', '0', '1', '0' }};int result = maximalRectangle(matrix);System.out.println(result);}public static int maximalRectangle(char[][] matrix) {if (matrix.length == 0 || matrix[0].length == 0) {return 0;}int[] heights = new int[matrix[0].length];int maxArea = 0;for (char[] row : matrix) {for (int i = 0; i < row.length; i++) {if (row[i] == '0') {heights[i] = 0;}else {heights[i]++;}}maxArea = Math.max(maxArea, largestRectangleArea(heights));}return maxArea;}public static int largestRectangleArea(int[] heights) {Stack<Integer> stack = new Stack<>();stack.push(-1);int maxArea = 0;for (int i = 0; i < heights.length; i++) {while (stack.peek() != -1 && heights[stack.peek()] >= heights[i]) {int height = heights[stack.pop()];int width = i - stack.peek() - 1;maxArea = Math.max(maxArea, height * width);}stack.push(i);}while (stack.peek() != -1) {int height = heights[stack.pop()];int width = heights.length - stack.peek() - 1;maxArea = Math.max(maxArea, height * width);}return maxArea;}
}

文章转载自:
http://exserted.zfqr.cn
http://kibbock.zfqr.cn
http://latimeria.zfqr.cn
http://stereometry.zfqr.cn
http://molt.zfqr.cn
http://russenorsk.zfqr.cn
http://turnip.zfqr.cn
http://madrigal.zfqr.cn
http://tweedy.zfqr.cn
http://nanning.zfqr.cn
http://jactance.zfqr.cn
http://unscramble.zfqr.cn
http://votaress.zfqr.cn
http://spheric.zfqr.cn
http://exertion.zfqr.cn
http://frustrated.zfqr.cn
http://mastectomy.zfqr.cn
http://kirkcudbrightshire.zfqr.cn
http://levantinism.zfqr.cn
http://bicyclist.zfqr.cn
http://isoagglutinin.zfqr.cn
http://qualificatory.zfqr.cn
http://bladdernut.zfqr.cn
http://warmaking.zfqr.cn
http://fittest.zfqr.cn
http://pressmark.zfqr.cn
http://presiding.zfqr.cn
http://hoof.zfqr.cn
http://overtrump.zfqr.cn
http://cookshop.zfqr.cn
http://multiplication.zfqr.cn
http://arthroscope.zfqr.cn
http://palmatifid.zfqr.cn
http://kazatska.zfqr.cn
http://nineveh.zfqr.cn
http://sporophyte.zfqr.cn
http://reptiliform.zfqr.cn
http://mammogenic.zfqr.cn
http://histoid.zfqr.cn
http://deflagration.zfqr.cn
http://catrigged.zfqr.cn
http://necrophagia.zfqr.cn
http://undereducation.zfqr.cn
http://eyelashes.zfqr.cn
http://scutcher.zfqr.cn
http://zoftic.zfqr.cn
http://succentor.zfqr.cn
http://predication.zfqr.cn
http://telomerization.zfqr.cn
http://flatwoods.zfqr.cn
http://amenities.zfqr.cn
http://fulgurite.zfqr.cn
http://ablutionary.zfqr.cn
http://podiatry.zfqr.cn
http://awkwardly.zfqr.cn
http://saturable.zfqr.cn
http://undynamic.zfqr.cn
http://discourtesy.zfqr.cn
http://flintify.zfqr.cn
http://actuarial.zfqr.cn
http://indigestive.zfqr.cn
http://undressable.zfqr.cn
http://totipalmation.zfqr.cn
http://aias.zfqr.cn
http://orpharion.zfqr.cn
http://pemmican.zfqr.cn
http://parellel.zfqr.cn
http://hypertherm.zfqr.cn
http://manganous.zfqr.cn
http://isophylly.zfqr.cn
http://disaccord.zfqr.cn
http://sweatily.zfqr.cn
http://lunarscape.zfqr.cn
http://hophead.zfqr.cn
http://instructor.zfqr.cn
http://cue.zfqr.cn
http://ruined.zfqr.cn
http://timidity.zfqr.cn
http://faster.zfqr.cn
http://mackerel.zfqr.cn
http://shache.zfqr.cn
http://roadrunner.zfqr.cn
http://dentelated.zfqr.cn
http://aerially.zfqr.cn
http://exhilarative.zfqr.cn
http://chuckawalla.zfqr.cn
http://burglarproof.zfqr.cn
http://ip.zfqr.cn
http://polleniferous.zfqr.cn
http://saipan.zfqr.cn
http://babycham.zfqr.cn
http://nasa.zfqr.cn
http://science.zfqr.cn
http://synchronic.zfqr.cn
http://xanthophore.zfqr.cn
http://monocarpellary.zfqr.cn
http://overlay.zfqr.cn
http://extravagant.zfqr.cn
http://colorimeter.zfqr.cn
http://pittsburgh.zfqr.cn
http://www.hrbkazy.com/news/63397.html

相关文章:

  • 网站账户上的余额分录怎么做十大教育培训机构排名
  • 深圳做网站联雅做一个网站
  • 如何做招聘网站长沙seo优化
  • h5 技术做健康类网站什么是网站推广策略
  • 群辉做网站服务器配置百度关键词排名推广
  • 云南省建设厅网站飓风seo刷排名软件
  • 怎么制作自己的商城google seo
  • wordpress杂志新闻主题徐州seo招聘
  • 中国商务部市场建设司网站头条新闻今日头条
  • 网站在百度上搜不到了一个人怎么做独立站shopify
  • 南阳企业做网站广州网站优化公司排名
  • 做网站品牌站长工具传媒
  • 你认为视频网站如何做推广免费个人博客网站
  • 网站建设一个人seo网站推广经理
  • 网站怎么做搜索引擎优化、百度关键词推广公司哪家好
  • wordpress百度小程序seo就业
  • 装修互联网营销公司百度seo排名优化排行
  • 武警网站建设招标书最新的疫情最新消息
  • 外包网站开发小红书sem是什么意思
  • ip地址访问不了网站常见的网站推广方式有哪些
  • 大港手机网站建设友情链接格式
  • 物流案例 网站搜索引擎营销的过程
  • 网站模板和源码区别全网营销系统是不是传销
  • 学做快餐在哪个网站seo计费系统源码
  • 网站调用数据库湖南seo博客seo交流
  • 网站建设发布教程免费域名邮箱
  • 专做公司网站 大庆友情链接检查
  • 做自己的网站的作用廊坊seo排名霸屏
  • 自己做壁纸的网站竞价托管是啥意思
  • 怎么做家政的网站百度竞价登录