无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

LeetCode 1313. Decompress Run-Length Encoded List

2023-05-25 11:36 作者:您是打尖兒還是住店呢  | 我要投稿

We are given a list?nums?of integers representing a list compressed with run-length encoding.

Consider each adjacent pair?of elements?[freq, val] = [nums[2*i], nums[2*i+1]]?(with?i >= 0).? For each such pair, there are?freq?elements with value?val?concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.

Return the decompressed list.

?

Example 1:

Input: nums = [1,2,3,4]Output: [2,4,4,4]Explanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2]. The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4]. At the end the concatenation [2] + [4,4,4] is [2,4,4,4].

Example 2:

Input: nums = [1,1,2,3]Output: [1,3,3]

?

Constraints:

  • 2 <= nums.length <= 100

  • nums.length % 2 == 0

  • 1 <= nums[i] <= 100

依次遍歷,放到list中,然后將list放到數(shù)組中。list有toarray的方法,但是老報(bào)錯(cuò),還是用原始的方法了。

下面是代碼:

Runtime:?4 ms, faster than?55.94%?of?Java?online submissions for?Decompress Run-Length Encoded List.

Memory Usage:?44.5 MB, less than?5.84%?of?Java?online submissions for?Decompress Run-Length Encoded List.


LeetCode 1313. Decompress Run-Length Encoded List的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
云霄县| 海阳市| 壶关县| 安福县| 闽清县| 新巴尔虎左旗| 嵩明县| 万宁市| 青神县| 申扎县| 资兴市| 富阳市| 屏东县| 江山市| 江都市| 卢湾区| 祥云县| 西丰县| 皋兰县| 康保县| 休宁县| 文成县| 遵化市| 潜江市| 秦皇岛市| 遵义县| 湘西| 娄烦县| 安远县| 泸定县| 海安县| 白城市| 张家川| 石首市| 义马市| 龙口市| 金湖县| 福州市| 翁牛特旗| 梅州市| 府谷县|