---
# System prepended metadata

title: 0605. Can Place Flowers
tags: [Leetcode, FaceBook, Easy]

---

# 0605. Can Place Flowers
###### tags: `Leetcode` `FaceBook` `Easy`
Link: https://leetcode.com/problems/can-place-flowers/
## 思路
其实很简单 但是写的时候edge case没处理好 建议再写一遍~~
## Code
```java=
class Solution {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        if(flowerbed.length == 1 && flowerbed[0]==0) return true;
        for(int i = 0;i < flowerbed.length;i++){
            if(flowerbed[i] == 0){
                if((i==0||flowerbed[i-1]==0)&&(i==flowerbed.length-1||flowerbed[i+1]==0)){
                    flowerbed[i] = 1;
                    n--;
                }
            }
        }
        return n<=0;
    }
}
```