5. Find the Number of Islands
Problem Description
Examples
Example 1:
grid[][] = [['L', 'L', 'W', 'W', 'W'],
['W', 'L', 'W', 'W', 'L'],
['L', 'W', 'W', 'L', 'L'],
['W', 'W', 'W', 'W', 'W'],
['L', 'W', 'L', 'L', 'W']]4Example 2:
Constraints:
My Approach
DFS (Recursive Flood Fill – 8 Directions)
Algorithm Steps:
Time and Auxiliary Space Complexity:
Code (C++)
Code (Java)
Code (Python)
Contribution and Support:
📍Visitor Count
Last updated