We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def cavityMap(grid):
if n < 3:
return grid
else:
for idx, row in enumerate(grid[1:-1]):
for jdx, i in enumerate(row[1:-1]):
if all([grid[idx][jdx+1]<i, grid[idx+2][jdx+1]<i,
row[jdx] < i , row[jdx+2] < i]):
grid[idx+1] = grid[idx+1][:jdx+1] + 'X' + grid[idx+1][jdx+2:]
return grid
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cavity Map
You are viewing a single comment's thread. Return to all comments →
I employed a very similar method: