Can Place Flowers

给一个数组, 里面的1代表一个花, 花之间不能相邻别的花, 给一个数n, 求这个数组能不能放下n个花.

class Solution {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        int m = 0; 
        while(true){
            boolean put = false;
            for(int i = 0; i < flowerbed.length; i++) {
                if(flowerbed[i] == 0){
                    if(((i - 1 >= 0 && flowerbed[i - 1] == 0) || i - 1 < 0) && ((i + 1 < flowerbed.length && flowerbed[i + 1] == 0) || (i + 1 >= flowerbed.length)) && n > 0){
                        flowerbed[i] = 1;
                        n--;w
                        put = true;
                        break;
                    } 
            }
            } 
            if(n == 0)
                return true;
            if(!put)
                return false;
        } 
    }
}