Grid Challenge Discussions | | HackerRank

Grid Challenge

Sort by

recency

|

481 Discussions

|

  • + 0 comments

    Yeah kinda annoying for them to say square grid which implies elements in input have the same length as the number of inputs.

  • + 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!