From 285b714158bc0dd6b1b2583cbc9109d846f09298 Mon Sep 17 00:00:00 2001
From: HarshitJain28 <harshit.nj@somaiya.edu>
Date: Sun, 17 Oct 2021 00:01:41 +0530
Subject: [PATCH] Added 695. Max Area of Island in Python

---
 Python/695. Max Area Of Island.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Python/695. Max Area Of Island.py

diff --git a/Python/695. Max Area Of Island.py b/Python/695. Max Area Of Island.py
new file mode 100644
index 0000000..77c53b1
--- /dev/null
+++ b/Python/695. Max Area Of Island.py	
@@ -0,0 +1,22 @@
+class Solution:
+    def maxAreaOfIsland(self, grid: List[List[int]]) -> int:
+        def explore(grid, r, c, visited):
+            rowInbound = 0 <= r <len(grid)
+            colInbound = 0 <= c < len(grid[0])
+            
+            if not(rowInbound) or not(colInbound):return 0
+            if grid[r][c] == 0: return 0
+            elem = str(r)+','+str(c)
+            if visited.__contains__(elem): return 0
+            visited.add(elem)
+          
+            
+            return 1 + explore(grid,r-1,c,visited) + explore(grid,r+1,c,visited)+explore(grid,r,c+1,visited) + explore(grid,r,c-1,visited)
+        
+        visited = set()
+        max_c = 0
+        for i in range(len(grid)):
+            for j in range(len(grid[0])):
+                max_c = max(max_c,explore(grid,i,j,visited))
+        return max_c
+        
\ No newline at end of file