Skip to content

Practice Delete Columns to Make Sorted

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#944
LeetCode Problem

Delete Columns to Make Sorted

Problem Statement

Place each equal-length string in strs on its own row, keeping the given row order. A column is sorted when its characters are nondecreasing from top to bottom. Count the columns that violate this condition and therefore must be deleted.

Source: Delete Columns to Make Sorted on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
strs = ["cba","daf","ghi"]
Output
1

# Example 2

Input
strs = ["a","b"]
Output
0

# Example 3

Input
strs = ["zyx","wvu","tsr"]
Output
3

Constraints

n == strs.length
1 <= n <= 100
1 <= strs[i].length <= 1000
strs[i] consists of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Delete Columns to Make Sorted.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.