Problem Submissions Solution

Making A Large Island

Difficulty: Hard

Acceptance: %

Points: 40.00

You are given an n x n binary matrix grid[][]. You are allowed to change at most one 0 to 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.

Topics

Companies

Articles

Examples:

Time Complexity: O(N^2)

Space Complexity: O(N^2)

Constraints:
  • 1 <= n <= 500
  • 0 <= grid[i][j] <= 1
Companies:
Walmart Intuit Infosys
Topics:
Graph BFS DFS
Locked Content
Access Restricted: Please Login to access the code editor and test cases.