1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/ 字母与数字(English) [find-longest-subarray-lcci].html

26 lines
1.1 KiB
HTML

<p>Given an array filled with letters and numbers, find the longest subarray with an equal number of letters and numbers.</p>
<p>Return the subarray. If there are more than one answer, return the one which has the smallest&nbsp;index of its left endpoint. If there is no answer, return an empty arrary.</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input: </strong>[&quot;A&quot;,&quot;1&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;E&quot;,&quot;5&quot;,&quot;F&quot;,&quot;G&quot;,&quot;6&quot;,&quot;7&quot;,&quot;H&quot;,&quot;I&quot;,&quot;J&quot;,&quot;K&quot;,&quot;L&quot;,&quot;M&quot;]
<strong>Output: </strong>[&quot;A&quot;,&quot;1&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;E&quot;,&quot;5&quot;,&quot;F&quot;,&quot;G&quot;,&quot;6&quot;,&quot;7&quot;]
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input: </strong>[&quot;A&quot;,&quot;A&quot;]
<strong>Output: </strong>[]
</pre>
<p><strong>Note: </strong></p>
<ul>
<li><code>array.length &lt;= 100000</code></li>
</ul>