NeetCode #586LC-1162MediumGraphs
← Back to All Problems

#586 · #1162 · As Far from Land as Possible(地图分析)

📌 Problem Statement & Constraints

Given an n x n grid containing only 0 (water) and 1 (land), return the maximum Manhattan distance from a water cell to its nearest land cell, or -1 if no water or no land exists. Constraints: 1 <= n <= 100.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!