Skip to content

Commit ca75d25

Browse files
committed
working commit - Created using LeetHub
1 parent d64bb48 commit ca75d25

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<h2>unknown-problem</h2><h3>Easy</h3><hr><div><p>We are given an array&nbsp;<code>A</code> of <code>N</code> lowercase letter strings, all of the same length.</p>
2+
3+
<p>Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.</p>
4+
5+
<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>,&nbsp;and the remaining columns of <code>A</code> are&nbsp;<code>["b","v"]</code>, <code>["e","y"]</code>, and <code>["f","z"]</code>.&nbsp; (Formally, the <code>c</code>-th column is <code>[A[0][c], A[1][c], ..., A[A.length-1][c]]</code>).</p>
6+
7+
<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>
8+
9+
<p>Return the minimum possible value of <code>D.length</code>.</p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong>Example 1:</strong></p>
13+
14+
<pre><strong>Input:</strong> A = ["cba","daf","ghi"]
15+
<strong>Output:</strong> 1
16+
<strong>Explanation: </strong>
17+
After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
18+
If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
19+
</pre>
20+
21+
<p><strong>Example 2:</strong></p>
22+
23+
<pre><strong>Input:</strong> A = ["a","b"]
24+
<strong>Output:</strong> 0
25+
<strong>Explanation: </strong>D = {}
26+
</pre>
27+
28+
<p><strong>Example 3:</strong></p>
29+
30+
<pre><strong>Input:</strong> A = ["zyx","wvu","tsr"]
31+
<strong>Output:</strong> 3
32+
<strong>Explanation: </strong>D = {0, 1, 2}
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
<p><strong>Constraints:</strong></p>
37+
38+
<ul>
39+
<li><code>1 &lt;= A.length &lt;= 100</code></li>
40+
<li><code>1 &lt;= A[i].length &lt;= 1000</code></li>
41+
</ul>
42+
</div>

0 commit comments

Comments
 (0)