Android Developer Blog
AboutLeetCode

LeetCode Entry

944. Delete Columns to Make Sorted

3.01.2023 easy 2023 kotlin

fun minDeletionSize(strs: Array): Int =

944. Delete Columns to Make Sorted easy

https://t.me/leetcode_daily_unstoppable/73

blog post

    fun minDeletionSize(strs: Array<String>): Int =
       (0..strs[0].lastIndex).asSequence().count { col ->
           (1..strs.lastIndex).asSequence().any { strs[it][col] < strs[it-1][col] }
        }

Just do what is asked. We can use Kotlin’s sequence api.

Space: O(1), Time: O(wN)

Patterns

String Array

AI Tags

The problem is solved by checking for inversions across columns to determine which columns must be deleted to make the remaining string array sorted.

Collections

Repeat Lab Evolution

Links

LeetCode Kotlin Telegram Raw archive

Subscribe

This is a personal blog. Mail me if you want to use materials from it.

  • samoylenkodmitry
  • DmitrySamoylenk