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:
WalmartIntuitInfosys
Topics:
GraphBFSDFS
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.