453. Can Place Flowers
EasyGreedy
A flowerbed is 0 (empty) and 1 (planted); flowers cannot be adjacent. Print YES if k new flowers can be planted, else NO.
Input format
Line 1: n k Line 2: n bits
Output format
YES or NO
Example 1
Input
5 1 1 0 0 0 1
Output
YES
Example 2
Input
5 2 1 0 0 0 1
Output
NO
Constraints
1 ≤ n ≤ 2 × 10⁴
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…