Back to problems

Making a Large Island

Algorithm · Uber · Medium

You receive an n x n grid containing only binary values. You can convert no more than one 0 cell into a 1 cell. Determine the greatest possible area of an island after that optional conversion. An island consists of 1 cells joined through their top, bottom, left, or right sides. Examples Example 1: Input: grid = [[0,1],[1,0]] Output: 3 Explanation: Changing either 0 joins the two existing 1 cells with the flipped cell, producing an island of three cells. Example 2: Input:…

Checking your access…