Skip to content

Commit 5aabde3

Browse files
committed
Fix code review issues and SRI hashes for LeetCode 2625 solution
1 parent a444b04 commit 5aabde3

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

JavaScript/2625. Flatten Deeply Nested Array/Claude Code Sonnet 4.5 extended/FlattenDeeplyNestedArray_TS.ipynb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"|---------|----------|-----------|------------|---------|-------|-----|\n",
3131
"| 再帰的展開 | O(N) | O(N + D) | 低 | 高 | 高 | N=全要素数、D=深さ。最も直感的 |\n",
3232
"| スタック反復 | O(N) | O(N + D) | 中 | 高 | 中 | スタックオーバーフロー回避可能 |\n",
33-
"| reduce連鎖 | O(N) | O(N + D) | 中 | 中 | 中 | 関数型スタイル、やや複雑 |\n",
33+
"| reduce連鎖 | O(N²) | O(N + D) | 中 | 中 | 中 | 関数型スタイル、やや複雑 |\n",
3434
"\n",
3535
"## 3. 選択したアルゴリズムと理由\n",
3636
"\n",
@@ -175,7 +175,7 @@
175175
"### パフォーマンス考察\n",
176176
"\n",
177177
"- **再帰呼び出しコスト**: 現代のJSエンジンは末尾再帰最適化を持たないが、制約範囲(depth ≤ 1000)では問題なし\n",
178-
"- **配列操作**: `push(...array)` は一度に複数要素を追加するため、ループより効率的\n",
178+
"- **配列操作**: `push(...array)` はスプレッド展開により内部で配列を反復・割り当てするため、ホットパスでは明示的なループより遅い場合がある(本実装では `push(...flattened)` を要素ごとの `push` に変更することで156ms→80msに改善)\n",
179179
"- **メモリ**: 結果配列は避けられないO(N)。コールスタックはO(D)で十分小さい"
180180
]
181181
},
@@ -522,12 +522,6 @@
522522
"| スタック初期化 | `[[arr, 0]]` | `arr` の各要素を個別に `[arr[i], 0]` として追加 |\n",
523523
"| depth判定 | `if (depth < n)` のみ | `if (Array.isArray(item) && depth < n)` |\n"
524524
]
525-
},
526-
{
527-
"cell_type": "markdown",
528-
"id": "253e2ebb",
529-
"metadata": {},
530-
"source": []
531525
}
532526
],
533527
"metadata": {
@@ -545,4 +539,4 @@
545539
},
546540
"nbformat": 4,
547541
"nbformat_minor": 5
548-
}
542+
}

JavaScript/2625. Flatten Deeply Nested Array/Claude Code Sonnet 4.5 extended/README_react.html

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,40 @@
2020
<link
2121
rel="stylesheet"
2222
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css"
23+
integrity="sha384-wFjoQjtV1y5jVHbt0p35Ui8aV8GVpEZkyF99OXWqP/eNJDU93D3Ugxkoyh6Y2I4A"
24+
crossorigin="anonymous"
2325
/>
2426
<link
2527
rel="stylesheet"
2628
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css"
29+
integrity="sha384-nUkTNLI8COlMCRJ0FHIdX76If83145OTCLUx4gQyfnO0gGeO/sD9czGEUBxtkcUv"
30+
crossorigin="anonymous"
2731
/>
2832
<link
2933
rel="stylesheet"
3034
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.css"
35+
integrity="sha384-EUzJ34/1CCeefTGUKLgvA5Z/vYIwi+Jyu8aAaCfFDxfwZ3Xs3OfkkIeegsLRM11e"
36+
crossorigin="anonymous"
3137
/>
3238

33-
<!-- React & ReactDOM -->
34-
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
39+
<!-- React & ReactDOM (Production) -->
3540
<script
36-
crossorigin
37-
src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
41+
crossorigin="anonymous"
42+
src="https://unpkg.com/react@18/umd/react.production.min.js"
43+
integrity="sha384-DGyLxAyjq0f9SPpVevD6IgztCFlnMF6oW/XQGmfe+IsZ8TqEiDrcHkMLKI6fiB/Z"
44+
></script>
45+
<script
46+
crossorigin="anonymous"
47+
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
48+
integrity="sha384-gTGxhz21lVGYNMcdJOyq01Edg0jhn/c22nsx0kyqP0TxaV5WVdsSH1fSDUf5YJj1"
3849
></script>
3950

4051
<!-- Babel Standalone -->
41-
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
52+
<script
53+
src="https://unpkg.com/@babel/standalone/babel.min.js"
54+
integrity="sha384-Fo0OdKhdnE7y2WmzjOMW4PYjHkkANeu1501pWTqKrzAPeJMFQb4ZTdAA9dtrVUJV"
55+
crossorigin="anonymous"
56+
></script>
4257

4358
<style>
4459
* {
@@ -773,7 +788,7 @@ <h4 class="font-bold text-slate-800 mb-2">4. エッジケース</h4>
773788
stroke-dasharray="8,4"
774789
/>
775790
<rect
776-
x="775"
791+
x="755"
777792
y="450"
778793
width="120"
779794
height="32"
@@ -783,7 +798,7 @@ <h4 class="font-bold text-slate-800 mb-2">4. エッジケース</h4>
783798
stroke-width="2"
784799
/>
785800
<text
786-
x="835"
801+
x="815"
787802
y="466"
788803
text-anchor="middle"
789804
dominant-baseline="middle"
@@ -1397,7 +1412,7 @@ <h4 class="font-bold text-orange-900 mb-2">💡 最適化の考察</h4>
13971412
</text>
13981413

13991414
<path
1400-
d="M 330 90 L 360 90"
1415+
d="M 330 90 L 370 90"
14011416
stroke="#10b981"
14021417
strokeWidth="3"
14031418
fill="none"
@@ -1513,7 +1528,7 @@ <h4 class="font-bold text-orange-900 mb-2">💡 最適化の考察</h4>
15131528
</text>
15141529

15151530
<path
1516-
d="M 330 95 L 360 95"
1531+
d="M 330 95 L 370 95"
15171532
stroke="#a855f7"
15181533
strokeWidth="3"
15191534
fill="none"
@@ -1621,7 +1636,7 @@ <h4 class="font-bold text-orange-900 mb-2">💡 最適化の考察</h4>
16211636
</text>
16221637

16231638
<path
1624-
d="M 330 90 L 360 90"
1639+
d="M 330 90 L 370 90"
16251640
stroke="#10b981"
16261641
strokeWidth="3"
16271642
fill="none"
@@ -1737,7 +1752,7 @@ <h4 class="font-bold text-orange-900 mb-2">💡 最適化の考察</h4>
17371752
</text>
17381753

17391754
<path
1740-
d="M 330 95 L 360 95"
1755+
d="M 330 95 L 370 95"
17411756
stroke="#c026d3"
17421757
strokeWidth="3"
17431758
fill="none"
@@ -1878,7 +1893,7 @@ <h4 class="font-bold text-orange-900 mb-2">💡 最適化の考察</h4>
18781893
return () => {
18791894
if (timerRef.current) clearTimeout(timerRef.current);
18801895
};
1881-
}, [isPlaying, activeStep]);
1896+
}, [isPlaying, activeStep, stepsData.length]);
18821897

18831898
const handlePlay = () => {
18841899
if (isPlaying) return;

0 commit comments

Comments
 (0)