Grid Challenge Discussions | | HackerRank

Grid Challenge

Sort by

recency

|

480 Discussions

|

  • + 0 comments

    Problem and tests are not consistent, the problem states square grids but the test have non square grids.

  • + 0 comments

    Scala Solution

    def gridChallenge(grid: Array[String]): String = {
        // Write your code here
        val sortedGrid = grid.map(row => row.sorted)
        val n = sortedGrid.length
        val m = sortedGrid(0).length
        for (col <- 0 until m) {
        for (row <- 0 until n - 1) {
          if (sortedGrid(row)(col) > sortedGrid(row + 1)(col)) {
            return "NO"
          }
        }
      }
    
      "YES"
    
    
        }
    
  • + 0 comments

    I had to assume column length can differ from number of strings/rows/n;

    int cols = grid[0].Length;

  • + 0 comments

    Using JS, I couldn't get test case 10 to work.

    It is too large for a custom input to test and doing it manually I got pretty deep into the test case file and was passing all the test cases,

    I passed all other test cases...and got it to work with Python, so yay...

    Not to mention the lies about the 'n' variable in the description.

    Overall, this was a great problem!

  • + 0 comments

    Python3

    def gridChallenge(grid):
        columns = [0] * len(grid[0])
        for index in range(len(grid)):
            row = [ord(c) for c in grid[index]]
            row.sort()        
            for c in range(len(row)):
                if columns[c] > row[c]:
                    return 'NO'
                columns[c] = row[c]
        return 'YES'``