tungggg

flower

May 11th, 2022
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. bool canPlaceFlowers(int flowerbed[], int n , int k ){
  2.     for (int i=0;i<n;i++){
  3.         if (i==0 ){
  4.             if (a[i]==0 && a[i+1]==0 ){
  5.                 a[i]=1;
  6.                 k--;
  7.             }
  8.         }
  9.         else {
  10.             if ( a[i]==0 && a[i-1]==0 && a[i+1]==0 ){
  11.                 a[i]=1;
  12.                 k--;
  13.             }
  14.         }
  15.     }
  16.     if ( k<=0) return true ;
  17.     return false ;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment