```
public class Solution {
public boolean canPlaceFlowers(int[] flowerbed, int n) {
int arr[]=new int[flowerbed.length+2];
arr[0]=0;
arr[flowerbed.length+1]=0;
for(int i=0;i<flowerbed.length;i++){
arr[i+1]=flowerbed[i];
}
for(int i=1;i<=flowerbed.length;i++){
if(arr[i]==0 && ((arr[i-1] | arr[i+1])==0)){
n--;
arr[i]=1;
}
}
return n<=0?true:false;
}
}
```