We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3b82454 commit ab0078aCopy full SHA for ab0078a
605_canPlaceFlowers.cpp
@@ -2,6 +2,7 @@ class Solution {
2
public:
3
bool canPlaceFlowers(vector<int>& flowerbed, int n) {
4
int planted = 0;
5
+ // Use the case could be [0,0,0] n=2
6
// Add zeros to the beginning and end of the flowerbed to simplify boundary conditions
7
// This helps handle edge cases uniformly without extra checks for the first and last elements
8
flowerbed.insert(flowerbed.begin(), 0);
0 commit comments