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.
intsum=0;sum+=2*A.size()*A[0].size();// it will check count all the top bottom of the stackfor(inti=0;i<A.size();i++){for(intj=0;j<A[0].size();j++){//it checks, is there any board on north direction or notif(i==0){sum+=A[i][j];}else{sum+=max(0,A[i][j]-A[i-1][j]);}// it checks, is there any board on south direction or notif(i==A.size()-1){sum+=A[i][j];}else{sum+=max(0,A[i][j]-A[i+1][j]);}//it checks, is there any board on west direction or notif(j==0){sum+=A[i][j];}else{sum+=max(0,A[i][j]-A[i][j-1]);}//it checks, is there any board on east direction or notif(j==A[0].size()-1){sum+=A[i][j];}else{sum+=max(0,A[i][j]-A[i][j+1]);}}}returnsum;
Cookie support is required to access HackerRank
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 →