1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/解压缩编码列表 [decompress-run-length-encoded-list].html
2022-03-29 12:43:11 +08:00

34 lines
1.1 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个以行程长度编码压缩的整数列表 <code>nums</code> 。</p>
<p>考虑每对相邻的两个元素 <code>[freq, val] = [nums[2*i], nums[2*i+1]]</code> (其中 <code>i >= 0</code> ),每一对都表示解压后子列表中有 <code>freq</code> 个值为 <code>val</code> 的元素,你需要从左到右连接所有子列表以生成解压后的列表。</p>
<p>请你返回解压后的列表。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,4]
<strong>输出:</strong>[2,4,4,4]
<strong>解释:</strong>第一对 [1,2] 代表着 2 的出现频次为 1所以生成数组 [2]。
第二对 [3,4] 代表着 4 的出现频次为 3所以生成数组 [4,4,4]。
最后将它们串联到一起 [2] + [4,4,4] = [2,4,4,4]。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,1,2,3]
<strong>输出:</strong>[1,3,3]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 <= nums.length <= 100</code></li>
<li><code>nums.length % 2 == 0</code></li>
<li><code>1 <= nums[i] <= 100</code></li>
</ul>