From 16e06176566784098f6c48d1050a5441bfdd66e6 Mon Sep 17 00:00:00 2001 From: julienChemillier <66684524+julienChemillier@users.noreply.github.com> Date: Thu, 27 Oct 2022 10:06:35 +0200 Subject: [PATCH] Add 605 in c language --- c/605-can-place-flowers.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 c/605-can-place-flowers.c diff --git a/c/605-can-place-flowers.c b/c/605-can-place-flowers.c new file mode 100644 index 000000000..529f13fdf --- /dev/null +++ b/c/605-can-place-flowers.c @@ -0,0 +1,31 @@ +/* +Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not +empty, and an integer n, return if n new flowers can be planted in the flowerbed without +violating the no-adjacent-flowers rule. + +Space: O(1) +Time: O(n) +*/ + +bool canPlaceFlowers(int* flowerbed, int flowerbedSize, int n){ + int cpt = 0; // Count the number of flowers that can be added + int i=0; + while (i=n; +}