博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
摆桶问题
阅读量:4113 次
发布时间:2019-05-25

本文共 526 字,大约阅读时间需要 1 分钟。

条件的算法描述如下:

Given integer m and n where n is odd, for all mxn matrixes that consist of 0 and 1, find the one that has max count of 1s and meets following conditions:

  1. All 0s are connected;
  2. All 1s are adjacent to at least one 0 (Adjacent includes diagonal line adjacent, 8 directions);
  3. maxtrix[m-1][n/2] = 0.

Example :

Input: m=2, n=3

Output: [[1,1,1],[1,0,1]]

Follow up:

Given another list of ‘blocked’ points. Matrix will set those points to -1 and you cannot change that. Solve the problem again.

目前所得结果:

Max=135
如果有更高级解法,请指教~
在这里插入图片描述

你可能感兴趣的文章
C++模板
查看>>
【C#】如何实现一个迭代器
查看>>
【C#】利用Conditional属性完成编译忽略
查看>>
DirectX11 光照演示示例Demo
查看>>
VUe+webpack构建单页router应用(一)
查看>>
Node.js-模块和包
查看>>
(python版)《剑指Offer》JZ01:二维数组中的查找
查看>>
管理用户状态——Cookie与Session
查看>>
Spring MVC中使用Thymeleaf模板引擎
查看>>
PHP 7 的五大新特性
查看>>
深入了解php底层机制
查看>>
PHP中的stdClass 【转】
查看>>
XHProf-php轻量级的性能分析工具
查看>>
OpenCV gpu模块样例注释:video_reader.cpp
查看>>
【增强学习在无人驾驶中的应用】
查看>>
OpenCV meanshift目标跟踪总结
查看>>
就在昨天,全球 42 亿 IPv4 地址宣告耗尽!
查看>>
听说玩这些游戏能提升编程能力?
查看>>
如果你还不了解 RTC,那我强烈建议你看看这个!
查看>>
沙雕程序员在无聊的时候,都搞出了哪些好玩的小玩意...
查看>>