LeetCode 944. 删列造序
2022-5-14
| 2023-8-2
0  |  阅读时长 0 分钟
Created time
May 14, 2022 08:51 AM
date
status
category
Origin
summary
tags
type
URL
icon
password
slug

删列造序

给你由 n 个小写字母字符串组成的数组 strs,其中每个字符串长度相等。这些字符串可以每个一行,排成一个网格。例如,strs = ["abc", "bce", "cae"] 可以排列为:
你需要找出并删除 不是按字典序升序排列的 列。在上面的例子(下标从 0 开始)中,列 0('a', 'b', 'c')和列 2('c', 'e', 'e')都是按升序排列的,而列 1('b', 'c', 'a')不是,所以要删除列 1 。返回你需要删除的列数。

Delete Columns to Make Sorted

You are given an array of n strings strs, all of the same length. The strings can be arranged such that there is one on each line, making a grid. For example, strs = ["abc", "bce", "cae"] can be arranged as:
You want to delete the columns that are not sorted lexicographically. In the above example (0-indexed), columns 0 ('a', 'b', 'c') and 2 ('c', 'e', 'e') are sorted while column 1 ('b', 'c', 'a') is not, so you would delete column 1. Return the number of columns that you will delete.
  • n == strs.length
  • 1 <= n <= 100
  • 1 <= strs[i].length <= 1000
  • strs[i] 由小写英文字母组成 / strs[i] consists of lowercase English letters.
这个题的话是给我们一个矩阵,然后让我们判断一下不是单调递增的然后输出列数,所以这个题目直接模拟一遍就可以了,然后是代码怎么写:
 
yxc老师Acwing寒假每日一题2023LeetCode 933. 最近的请求次数
Loading...