|
15 | 15 |
|
16 | 16 | <p>Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.</p>
|
17 | 17 |
|
18 |
| -<p>For example, if we have an array <code>A = ["</code><code>abcdef</code><code>","uvwxyz"]</code> and deletion indices <code>{0, 2, 3}</code>, then the final array after deletions is <code>["bef", "vyz"]</code>, and the remaining columns of <code>A</code> are <code>["b"</code><code>,"</code><code>v"]</code>, <code>["e","y"]</code>, and <code>["f","z"]</code>. (Formally, the <code>c</code>-th column is <code>[A[0][c], A[1][c], ..., A[A.length-1][c]]</code>.)</p> |
| 18 | +<p>For example, if we have an array <code>A = ["abcdef","uvwxyz"]</code> and deletion indices <code>{0, 2, 3}</code>, then the final array after deletions is <code>["bef", "vyz"]</code>, and the remaining columns of <code>A</code> are <code>["b","v"]</code>, <code>["e","y"]</code>, and <code>["f","z"]</code>. (Formally, the <code>c</code>-th column is <code>[A[0][c], A[1][c], ..., A[A.length-1][c]]</code>).</p> |
19 | 19 |
|
20 | 20 | <p>Suppose we chose a set of deletion indices <code>D</code> such that after deletions, each remaining column in A is in <strong>non-decreasing</strong> sorted order.</p>
|
21 | 21 |
|
22 | 22 | <p>Return the minimum possible value of <code>D.length</code>.</p>
|
23 | 23 |
|
24 | 24 | <p> </p>
|
25 |
| - |
26 |
| -<div> |
27 | 25 | <p><strong>Example 1:</strong></p>
|
28 | 26 |
|
29 | 27 | <pre>
|
30 |
| -<strong>Input: </strong><span id="example-input-1-1">["cba","daf","ghi"]</span> |
31 |
| -<strong>Output: </strong><span id="example-output-1">1</span> |
| 28 | +<strong>Input:</strong> A = ["cba","daf","ghi"] |
| 29 | +<strong>Output:</strong> 1 |
32 | 30 | <strong>Explanation: </strong>
|
33 | 31 | After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
|
34 | 32 | If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
|
35 | 33 | </pre>
|
36 | 34 |
|
37 |
| -<div> |
38 | 35 | <p><strong>Example 2:</strong></p>
|
39 | 36 |
|
40 | 37 | <pre>
|
41 |
| -<strong>Input: </strong><span id="example-input-2-1">["a","b"]</span> |
42 |
| -<strong>Output: </strong><span id="example-output-2">0</span> |
| 38 | +<strong>Input:</strong> A = ["a","b"] |
| 39 | +<strong>Output:</strong> 0 |
43 | 40 | <strong>Explanation: </strong>D = {}
|
44 | 41 | </pre>
|
45 | 42 |
|
46 |
| -<div> |
47 | 43 | <p><strong>Example 3:</strong></p>
|
48 | 44 |
|
49 | 45 | <pre>
|
50 |
| -<strong>Input: </strong><span id="example-input-3-1">["zyx","wvu","tsr"]</span> |
51 |
| -<strong>Output: </strong><span id="example-output-3">3</span> |
| 46 | +<strong>Input:</strong> A = ["zyx","wvu","tsr"] |
| 47 | +<strong>Output:</strong> 3 |
52 | 48 | <strong>Explanation: </strong>D = {0, 1, 2}
|
53 | 49 | </pre>
|
54 | 50 |
|
55 | 51 | <p> </p>
|
| 52 | +<p><strong>Constraints:</strong></p> |
56 | 53 |
|
57 |
| -<p><strong><span>Note:</span></strong></p> |
58 |
| - |
59 |
| -<ol> |
| 54 | +<ul> |
60 | 55 | <li><code>1 <= A.length <= 100</code></li>
|
61 | 56 | <li><code>1 <= A[i].length <= 1000</code></li>
|
62 |
| -</ol> |
63 |
| -</div> |
64 |
| -</div> |
65 |
| -</div> |
| 57 | +</ul> |
66 | 58 |
|
67 | 59 | ### Related Topics
|
68 | 60 | [[Greedy](../../tag/greedy/README.md)]
|
0 commit comments