Back to problems

Walls and Gates / Max Area of Island

Algorithm · Meta · Medium

Requirements Walls and Gates (LC 286) You receive a grid containing INF for open rooms, -1 for barriers, and 0 for gates. Replace each open room with its shortest distance to any gate. Max Area of Island (LC 695) Given a matrix of 0s and 1s, find the cell count of the largest island formed by 4-directionally adjacent 1s. Examples LC 286: Input: Output: Each non-wall room receives the length of its shortest 4-directional path to either gate. LC 695: Input: Output: 3 The…

Checking your access…