You are viewing a single comment's thread. Return to all comments →
javascript
function surfaceArea(A) { let besides = [[1,0],[-1,0],[0,1],[0,-1]] let surface = 0 for(let i=0; i<A.length; i++){ for(let j=0; j<A[0].length; j++){ surface += 2 for(let [r,h] of besides){ surface += Math.max(A[i][j] - (A[i+r]?.[j+h] || 0), 0); } } } return surface }
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 →
javascript