1 Star 0 Fork 0

Roderland/algorithm

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Question605.java 555 Bytes
一键复制 编辑 原始数据 按行查看 历史
Roderland 提交于 2021-01-01 14:04 +08:00 . add
package question;
public class Question605 {
public boolean canPlaceFlowers(int[] flowerbed, int n) {
int cnt = 0;
for (int i = 0; i < flowerbed.length; ) {
if (flowerbed[i] == 1) {
i += 2;
} else {
if (i + 1 >= flowerbed.length || flowerbed[i + 1] == 0) {
flowerbed[i] = 1;
cnt++;
i += 2;
} else {
i += 3;
}
}
}
return cnt >= n;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/Roderland/algorithm.git
git@gitee.com:Roderland/algorithm.git
Roderland
algorithm
algorithm
master

搜索帮助