Can Place Flowers
A easy-tier problem at 29% community acceptance, tagged with Array, Greedy. Reported in interviews at Nike and 8 others.
Can Place Flowers looks easy but trips up candidates who don't nail the greedy insight. You're given a flowerbed array where 1 means planted, 0 means empty, and you need to determine if you can plant n new flowers without violating the rule that no two flowers can be adjacent. Companies like Nike, LinkedIn, Microsoft, Airbnb, and Atlassian have asked this. The acceptance rate sits around 29%, meaning nearly 3 in 4 candidates fail it in the live assessment. If this problem hits your OA and you blank on the greedy approach, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Can Place Flowers"
Can Place Flowers is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe trap: most candidates iterate through the array and plant greedily at every valid position, then check the remaining count. That works, but the implementation is fragile. The actual pattern is simpler. For each position, you can plant if the slot is empty, the left neighbor isn't planted (or doesn't exist), and the right neighbor isn't planted (or doesn't exist). Greedy placement from left to right is optimal because planting early never blocks a later valid position. Common fail: off-by-one errors on boundary checks, or modifying the array and losing track of what's actually planted. The edge case nobody handles: an array of all zeros can accommodate a surprising number of flowers depending on length. When you're live and your first approach feels clunky, StealthCoder surfaces the clean boundary-checked solution instantly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Can Place Flowers recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Can Place Flowers interview FAQ
Why does the acceptance rate feel low for an 'easy' problem?+
The greedy insight is buried. Candidates often try brute-force validation or mess up the boundary logic. Under live pressure, the implementation feels harder than it should. Nailing the clean boundary check (left neighbor exists and is 0, right neighbor exists and is 0) separates solvers from blankers.
Is the greedy approach provably optimal?+
Yes. Planting a flower at the earliest valid position never prevents you from planting at a later valid position. This left-to-right greedy maximizes flower count, so if you can plant n flowers greedily, the answer is always true. No need for backtracking or DP.
What's the most common mistake?+
Boundary checks. Candidates forget that arrays have edges. If you're at index 0, there's no left neighbor. If you're at the last index, there's no right neighbor. Forgetting these checks causes index errors or wrong answers on edge cases like single-element arrays.
Do I need to modify the array?+
No, and it's a trap. Some candidates plant flowers by setting array slots to 1, but that requires careful tracking. Just count how many you can plant by checking the conditions without modifying. Cleaner, fewer bugs, and you can reuse the array if needed.
Is this still asked at major companies?+
Yes. Nine companies have reported it, including Microsoft, LinkedIn, and Airbnb. It's not a rare problem, so if you see it in your OA, treat it as a must-solve. The low acceptance rate means many miss it, so nailing it is a quick confidence boost in the loop.
Want the actual problem statement? View "Can Place Flowers" on LeetCode →