Grid Challenge Discussions | | HackerRank

Grid Challenge

  • + 0 comments

    Javascript

    function gridChallenge(grid: string[]): string { // Write your code here const sorted_grid = grid.map(row => Array.from(row).sort())

    for(let j=0; j<sorted_grid.length; j++){
        for(let i=0; i <sorted_grid.length-1; i++){
          if (sorted_grid[i+1][j] < sorted_grid[i][j]){
              return 'NO'
          }   
        }
    }
    
    return 'YES'
    

    }