You are viewing a single comment's thread. Return to all comments →
def cavityMap(n,grid): ans=[[0 for _ in range(n)] for _ in range(n)] for i in range(1,n-1): for j in range(1,n-1): mat=[int(grid[i][j+1]),int(grid[i-1][j]),int(grid[i+1][j]),int(grid[i][j-1])] if int(grid[i][j])>max(mat): ans[i][j]='X' for k in range(n): for l in range(n): if ans[k][l]=='X': pass else: ans[k][l]=grid[k][l] res=[] for row in ans: res.append(''.join(map(str,row))) return res
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Cavity Map
You are viewing a single comment's thread. Return to all comments →