Algorithm · Affirm · Medium
You are given an m × n 2D grid where every cell holds either a positive integer or 0. A positive integer marks land belonging to an island; a 0 represents water. An island consists of one or more land cells connected horizontally or vertically. Islands are isolated from each other by water. Your task is to compute the total sum of the largest integer found on each island. Constraints: 1 Input: grid = [ [0,2,0,0], [3,4,0,5], [0,0,0,6], [7,0,8,0] ] Output: 25 Explanation: The…
Checking your access…