• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 17, 2023 |1.4K Views
PROBLEM OF THE DAY: 16/10/2023 | Making A Large Island
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Devashsish Khare. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Graph but will also help you build up problem-solving skills.

In this problem, we are given, an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. A group of connected 1s forms an island. Two 1s are connected if they share one of their sides with each other.

Return the size of the largest island in the grid after applying this operation.

Example :

Input: 
grid = [[1,0],[0,1]]
Output:
3

Explanation:
Change any one 0 to 1 and connect two 1s, then we get an island with area = 3.

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems/making-a-large-island/1