👤

class Solution:
def largestArea(self,n:int,m:int,k:int, enemy : List[List[int]]) -> int:
# code here
r, c = [0], [0]
for e in enemy:
r.append(e[0])
c.append(e[1])
r.append(n+1)
c.append(m+1)
r.sort()
c.sort()
r_max, c_max = 0, 0
for i in range(1, len(r)):
if r[i]-r[i-1]-1 > r_max:
r_max = r[i]-r[i-1]-1
for i in range(1, len(c)):
if c[i]-c[i-1]-1 > c_max:
c_max = c[i]-c[i-1]-1
return r_max*c_max

id like someone to help me understand the logic behind this code the question is:
You live in Geek land. Geek land can be seen as a grid of shape N x M.Their are K enemy at K positions. Each enemy blocks the row and column to which it belongs. You have to find the largest continuous area that is not blocked.No two enemies share the same row or the same column.
You don't need to read input or print anything. Your task is to complete the function largestArea() which takes the size of geek land n,m and a 2-D matrix enemy of size k denoting the coordinates of the enemy's and need to return the largest area that is free?