leetCode605

开心一刻

class Solution {
public:
    bool canPlaceFlowers(vector& flowerbed, int n) {
        if(flowerbed.size() == 1) return !flowerbed[0] || !n;
        for(int i = 0;i=0 && !flowerbed[i-1])
                    {
                        flowerbed[i] = 1;
                        n--;
                    }
                    else if(i-1>=0 && i+1

 

你可能感兴趣的:(leetcode)