You are viewing a single comment's thread. Return to all comments →
python
def surfaceArea(A, H, W): res = 2 * H * W for i, row in enumerate(A): for j, col in enumerate(row): if i == 0: res += col else: res += max(0, col - A[i - 1][j]) if i == H - 1: res += col else: res += max(0, col - A[i + 1][j]) if j == 0: res += col else: res += max(0, col - A[i][j - 1]) if j == W - 1: res += col else: res += max(0, col - A[i][j + 1]) return res
Seems like cookies are disabled on this browser, please enable them to open this website
3D Surface Area
You are viewing a single comment's thread. Return to all comments →
python