Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool canPlaceFlowers(int flowerbed[], int n , int k ){
- for (int i=0;i<n;i++){
- if (i==0 ){
- if (a[i]==0 && a[i+1]==0 ){
- a[i]=1;
- k--;
- }
- }
- else {
- if ( a[i]==0 && a[i-1]==0 && a[i+1]==0 ){
- a[i]=1;
- k--;
- }
- }
- }
- if ( k<=0) return true ;
- return false ;
- }
Advertisement
Add Comment
Please, Sign In to add comment