Max Altitude of Islands
Given an m x n 2D grid which represents a map where positive integers represent elevation of land and 0‘s represent water, return the altitude of the highest point for each of the islands.
An island is surrounded by water and is formed by connecting adjacent lands either horizontally or vertically.
You may assume all four edges of the grid are surrounded by water.
Input:
map = [[1,1,1,1,0],
[1,8,0,10,0],
[1,1,0,0,0],
[0,0,0,0,0]
]
Output: 1 island with highest point is 10
This problem asks for the highest altitude in each island of a grid, where positive values are land heights and 0 represents water. Since an island is a connected component formed by horizontal or vertical adjacency, the natural approach is DFS or BFS to traverse each unvisited land cell and track the maximum value within that component. The sample grid contains separate islands, so the result is the peak height of each island.