You are given a 2D grid grid[][] consisting of '1' (land) and '0' (water). Your task is to count the number of islands. An island is formed by connecting adjacent land cells horizontally or vertically. All cells outside the grid are considered water. Return the total number of islands present in the grid.
Topics
Companies
Articles
Examples:
N/A
Constraints:
m == grid.length
n == grid[i].length
1 = m, n = 300
grid[i][j] is either '0' or '1'
Companies:
AmazonMicrosoftApple
Topics:
Recursion
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.