← AlgoMindset 75

Can Place Flowers

Easy🎙 Interview me on this

🧠 Before you code — what pattern fits?

You have a flowerbed in which some plots are planted (1) and some are not (0). Flowers cannot be planted in adjacent plots.

Given the flowerbed array and an integer n, return true if n new flowers can be planted without violating the no-adjacent-flowers rule.

([1,0,0,0,1], 1) → true

([1,0,0,0,1], 2) → false

🎬 Video explanation · NeetCode

Your solution runs against 3 unit tests, including edge and large-value cases.

Loading...

Test console · 3 unit tests

Submit your code to run it against all 3 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.