Tree Planting on a Grid (no adjacent trees)

Given an m x n grid grid representing land:

  • 1 means an existing tree
  • 0 means empty

You may plant new trees on empty cells, subject to:

  • No two trees (existing or newly planted) may be ad...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: