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

Links

LeetCode Kotlin Telegram Raw archive

Subscribe

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

  • samoylenkodmitry
  • DmitrySamoylenk