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.
defcavityMap(grid):# Write your code heren=len(grid)new_grid=grid.copy()foriinrange(1,n-1):forjinrange(1,n-1):current=grid[i][j]top=grid[i-1][j]bottom=grid[i+1][j]left=grid[i][j-1]right=grid[i][j+1]ifcurrent>topandcurrent>bottomandcurrent>leftandcurrent>right:new_grid[i]=new_grid[i][:j]+"X"+new_grid[i][j+1:]returnnew_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 →