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.
string gridChallenge(vector grid) {
bool ok = true;
int n = grid.size();
for (int i = 0; i < n; i++) {
sort(grid[i].begin(), grid[i].end()); //Sorting taking care of row's
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < grid[i].size()-1; j++) {
if(grid[j][i] > grid[j+1][i]) //Taking care of coloumb
{
return "NO";
}
}
}
return "YES";
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Grid Challenge
You are viewing a single comment's thread. Return to all comments →
Easiest approch I found on CPP:
string gridChallenge(vector grid) { bool ok = true; int n = grid.size();
}