Grid Challenge Discussions | Algorithms | HackerRank

Grid Challenge

  • + 0 comments

    Kotlin:

    fun gridChallenge(grid: Array<String>): String
    {
        val sorted_grid = grid.map { it.toCharArray().sorted() }
        
        for (i in 0..<grid.first().length)
        {
            val col_list = sorted_grid.map { it.get(i) }
            if (col_list != col_list.sortedBy { it }) return "NO"
        }
        
        return "YES"
    }