Grid Challenge Discussions | Algorithms | HackerRank

Grid Challenge

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/GPB-dpsvQ8Y

    string gridChallenge(vector<string> grid) {
        for(int i = 0; i < grid.size(); i++) sort(grid[i].begin(), grid[i].end());
        for(int col = 0; col < grid.size(); col++){
           for(int row = 1; row < grid.size(); row++)
                if(grid[row][col] < grid[row-1][col]) return "NO";
        }
        return "YES";
    }