← 返回 bytedance 的题目列表Check if n flowers can be planted without adjacent ones in flowerbed
类型:online_judge
bytedance
Given a flowerbed represented by an array of integers where 0 means empty and 1 means not empty, you cannot plant flowers in adjacent plots. Determine if you can plant a given number n of new flowers without violating this rule in the flowerbed. Implement the function def max_flowers(flowerbed: List[int], n: int) -> int. It returns a boolean indicating whether you can fulfill the requirement. Assume the array length does not exceed 2 * 10^4.
Example
Input
flowerbed = [1, 0, 0, 0, 1], n = 1