leetcode二维数组-LeetCode:力码

时间:2021-07-07 03:28:03
【文件属性】:
文件名称:leetcode二维数组-LeetCode:力码
文件大小:3KB
文件格式:ZIP
更新时间:2021-07-07 03:28:03
系统开源 leetcode二维数组力码 列表 #605. 可以放置鲜花 #581。 最短的未排序连续子阵列 #566。 重塑矩阵 #624。 数组中的最大距离 #532。 数组中的 K-diff 对 #414。 第三个最大数 细节 #605. 可以放花 问题描述: 假设你有一个很长的花坛,其中一些地块种了,一些没有。 但是,不能在相邻的地块中种植花卉——它们会争水,两者都会死亡。 给定一个花坛(表示为一个包含 0 和 1 的数组,其中 0 表示空,1 表示不空)和一个数字 n,如果可以在其中种植 n 朵新花而不违反无相邻花规则,则返回。 解决方案: public class Solution { public boolean canPlaceFlowers(int[] flowerbed, int n) { int count = 0; boolean output = false; int countZero = 1; //处理开头为0 boolean beginCountZero = false; for(int flower = 0;flower<flowerbed.length && c
【文件预览】:
LeetCode-master
----新建文本文档.txt(0B)
----README.md(7KB)
----.gitattributes(378B)

网友评论