Tuesday, December 27, 2022
A function to delete the columns that are not sorted lexicographically in a grid of words with n
length.
func minDeletionSize(strs []string) int {
if len(strs) <= 1 {
return 0
}
var deletedCols int
for i := range strs[0] {
fmt.Println(i)
for wordsIdx := 0; wordsIdx < len(strs)-1; wordsIdx++ {
if strs[wordsIdx][i] > strs[wordsIdx+1][i] {
deletedCols++
break
}
}
}
return deletedCols
}