bool canPlaceFlowers(int* flowerbed, int flowerbedSize, int n){
    if (n==0) return true;
    if(flowerbedSize==1){
        return !flowerbed[0];
    }
    else{
        if(flowerbed[0]==0 && flowerbed[1]==0){
            flowerbed[0]=1;
            n--;
        }
        for(int i=1; i<flowerbedSize && n; i++){
            if(flowerbed[i]==0 && flowerbed[i-1]==0 && (i==flowerbedSize-1 || flowerbed[i+1]==0)){
                flowerbed[i]=1;
                n--;
            }
        }
    }    
    return !n;   
}