1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-19 02:24:59 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -2,7 +2,7 @@
<p><strong>多维数组&nbsp;</strong>是一种包含整数或其他&nbsp;<strong>多维数组&nbsp;</strong>的递归数据结构。</p>
<p>数组 <strong>扁平化</strong> 是对数组的一种操作,定义是将原数组部分或全部子数组删除,并替换为该子数组中的实际元素。只有当嵌套的数组深度<code>n</code> 时,才应该执行扁平化操作。第一层数组中元素的深度被认为是 0。</p>
<p>数组 <strong>扁平化</strong> 是对数组的一种操作,定义是将原数组部分或全部子数组删除,并替换为该子数组中的实际元素。只有当嵌套的数组深度<code>n</code> 时,才应该执行扁平化操作。第一层数组中元素的深度被认为是 0。</p>
<p>请在没有使用内置方法&nbsp;<code>Array.flat</code> 的前提下解决这个问题。</p>
@@ -18,7 +18,7 @@ n = 0
[1, 2, 3, [4, 5, 6], [7, 8, [9, 10, 11], 12], [13, 14, 15]]
<strong>解释</strong>
传递深度 n=0 的多维数组将始终得到原始数组。这是因为 子数组(0) 的最小可能的深度不小于 n=0 。因此,任何子数组都不应该被平面化。
传递深度 n=0 的多维数组将始终得到原始数组。这是因为子数组(0)的最小可能的深度不小于 n = 0。因此,任何子数组都不应该被平面化。
</pre>
<p><strong class="example">示例 2</strong></p>
@@ -31,7 +31,7 @@ n = 1
[1, 2, 3, 4, 5, 6, 7, 8, [9, 10, 11], 12, 13, 14, 15]
<strong>解释</strong>
以 4 、7 和 13 开头的子数组都被扁平化了,这是因为它们的深度为 0 而 0 小于 1 。然而 [9,10,11] 其深度为 1 ,所以未被扁平化。</pre>
以 4 、7 和 13 开头的子数组都被扁平化了,这是因为它们的深度为 0 而 0 小于 1。然而 [9,10,11] 其深度为 1所以未被扁平化。</pre>
<p><strong class="example">示例 3</strong></p>
@@ -43,7 +43,7 @@ n = 2
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
<strong>解释</strong>
所有子数组的最大深度都为 1 。因此,它们都被扁平化了。</pre>
所有子数组的最大深度都为 1。因此它们都被扁平化了。</pre>
<p>&nbsp;</p>