"Max Area of Island solved with DFS in Java"

👇 📅 Day 80 of #100DaysOfLeetCode Problem: Max Area of Island (LeetCode #695) Approach: Used Depth-First Search (DFS) to explore each connected component (island) in the grid. Iterated through every cell in the grid. When a land cell (1) was found, initiated a DFS to count all connected land cells. Marked visited cells by changing their value (to avoid recounting). Tracked the maximum island area found during the traversal. Returned the largest area after exploring the entire grid. Complexity: ⏱️ Time: O(m × n) — every cell visited once 💾 Space: O(m × n) — recursion stack in the worst case 🔗 Problem Link: https://lnkd.in/dvUNduuZ 🔗 Solution Link: https://lnkd.in/djiVYpfe #LeetCode #100DaysOfCode #DFS #Graph #GridTraversal #MaxAreaOfIsland #FloodFill #CodingChallenge #ProblemSolving #Java #Algorithms #DataStructures #ProgrammingJourney #DailyCoding #BuildInPublic #TechCommunity #CodeEveryday

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories