944. Delete Columns to Make Sorted
給你一個字串陣列表示的矩陣,若該矩陣的行不是由字典序小到大排序則移除之,判斷
有幾個行需要移除。
Example:
Input: strs = ["cba","daf","ghi"]
Output: 1
Explanation: The grid looks as follows:
cba
daf
ghi
Columns 0 and 2 are sorted, but column 1 is not, so you only need to delete 1
column.
思路:
1.對每一個行遍歷並檢查是否有排序,若沒排序就讓removed加一。
2.返回removed。
Java Code: