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.
vector<string>cavityMap(vector<string>grid){//Check if the grid is big enough for cavitysif(grid.size()<3||grid.at(0).size()<3){returngrid;}//Result vector<string>result=grid;//Check for cavitiesfor(inti=1;i<(grid.size()-1);i++){for(intj=1;j<(grid.at(i).size()-1);j++){if(grid.at(i).at(j-1)<grid.at(i).at(j)&&grid.at(i).at(j+1)<grid.at(i).at(j)&&grid.at(i-1).at(j)<grid.at(i).at(j)&&grid.at(i+1).at(j)<grid.at(i).at(j)){result.at(i).at(j)='X';}}}returnresult;}
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 →
C++ solution for this problem