mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
29 lines
1.2 KiB
HTML
29 lines
1.2 KiB
HTML
<p>Given a list of millions of words, design an algorithm to create the largest possible rectangle of letters such that every row forms a word (reading left to right) and every column forms a word (reading top to bottom). The words need not be chosen consecutively from the list but all rows must be the same length and all columns must be the same height.</p>
|
|
|
|
|
|
|
|
<p>If there are more than one answer, return any one of them. A word can be used more than once.</p>
|
|
|
|
|
|
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input:</strong> <code>["this", "real", "hard", "trh", "hea", "iar", "sld"]</code>
|
|
|
|
<strong>Output:
|
|
|
|
</strong><code>[
|
|
|
|
"this",
|
|
|
|
"real",
|
|
|
|
"hard"</code>
|
|
|
|
]</pre>
|
|
|
|
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input:</strong> <code>["aa"]</code>
|
|
|
|
<strong>Output: </strong>["aa","aa"]</pre>
|
|
|
|
|
|
|
|
<p><strong>Notes: </strong></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>words.length <= 1000</code></li>
|
|
|
|
<li><code>words[i].length <= 100</code></li>
|
|
|
|
<li>It's guaranteed that all the words are randomly generated.</li>
|
|
|
|
</ul>
|
|
|