Merge branch 'krahets:main' into main

This commit is contained in:
yanedie 2024-12-04 02:07:55 +08:00 committed by GitHub
commit 76be14bbd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
70 changed files with 535 additions and 343 deletions

View File

@ -115,9 +115,9 @@ int main() {
int i = 1;
int l = abt.left(i), r = abt.right(i), p = abt.parent(i);
cout << "\n当前节点的索引为 " << i << ",值为 " << abt.val(i) << "\n";
cout << "其左子节点的索引为 " << l << ",值为 " << (l != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n";
cout << "其右子节点的索引为 " << r << ",值为 " << (r != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n";
cout << "其父节点的索引为 " << p << ",值为 " << (p != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n";
cout << "其左子节点的索引为 " << l << ",值为 " << (abt.val(l) != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n";
cout << "其右子节点的索引为 " << r << ",值为 " << (abt.val(r) != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n";
cout << "其父节点的索引为 " << p << ",值为 " << (abt.val(p) != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n";
// 遍历树
vector<int> res = abt.levelOrder();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,30 +1,24 @@
<!--Section: hero -->
<section data-md-color-scheme="slate" data-md-color-primary="grey" class="home-div"
style="height: min(100vh, 120vw); position: relative; margin-top:-2.4rem; padding: 0; overflow: hidden;">
<!-- Section: hero -->
<section data-md-color-scheme="slate" data-md-color-primary="grey" class="home-div" style="height: min(100vh, 120vw); position: relative; margin-top:-2.4rem; padding: 0; overflow: hidden;">
<!-- hero image -->
<img src="assets/hero/universe_bg.png" class="hero-bg" alt="">
<div class="hero-div">
<img src="assets/hero/ground.png" alt=""
style="position: absolute; width: auto; height: 26.445%; left: 28.211%; top: 54.145%;">
<img src="assets/hero/links.png" alt=""
style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
<img src="assets/hero/ground.png" alt="" style="position: absolute; width: auto; height: 26.445%; left: 28.211%; top: 54.145%;">
<img src="assets/hero/links.png" alt="" style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
<a href="chapter_introduction/">
<img src="assets/hero/astronaut.png" alt="" style="height: 46.673%; left: 35.413%; top: 24.343%;">
<span style="left: 52.244%; top: 20.919%;">初识算法</span>
</a>
<a href="chapter_computational_complexity/">
<img src="assets/hero/chapter_computational_complexity.png" alt=""
style="height: 12.347%; left: 36.267%; top: 37.653%;">
<img src="assets/hero/chapter_computational_complexity.png" alt="" style="height: 12.347%; left: 36.267%; top: 37.653%;">
<span style="left: 39.244%; top: 33.919%;">复杂度</span>
</a>
<a href="chapter_array_and_linkedlist/">
<img src="assets/hero/chapter_array_and_linkedlist.png" alt=""
style="height: 22.242%; left: 73.242%; top: 52.481%;">
<img src="assets/hero/chapter_array_and_linkedlist.png" alt="" style="height: 22.242%; left: 73.242%; top: 52.481%;">
<span style="left: 90.897%; top: 76.259%;">数组与链表</span>
</a>
<a href="chapter_stack_and_queue/">
<img src="assets/hero/chapter_stack_and_queue.png" alt=""
style="height: 14.302%; left: 62.646%; top: 77.875%;">
<img src="assets/hero/chapter_stack_and_queue.png" alt="" style="height: 14.302%; left: 62.646%; top: 77.875%;">
<span style="left: 77.571%; top: 91.25%;">栈与队列</span>
</a>
<a href="chapter_hashing/">
@ -52,8 +46,7 @@
<span style="left: 28.805%; top: 53.808%;">排序</span>
</a>
<a href="chapter_divide_and_conquer/">
<img src="assets/hero/chapter_divide_and_conquer.png" alt=""
style="height: 18.681%; left: 32.721%; top: 4.816%;">
<img src="assets/hero/chapter_divide_and_conquer.png" alt="" style="height: 18.681%; left: 32.721%; top: 4.816%;">
<span style="left: 31.42%; top: 8.679%;">分治</span>
</a>
<a href="chapter_backtracking/">
@ -61,8 +54,7 @@
<span style="left: 4.742%; top: 50.113%;">回溯</span>
</a>
<a href="chapter_dynamic_programming/">
<img src="assets/hero/chapter_dynamic_programming.png" alt=""
style="height: 15.47%; left: 9.406%; top: 57.472%;">
<img src="assets/hero/chapter_dynamic_programming.png" alt="" style="height: 15.47%; left: 9.406%; top: 57.472%;">
<span style="left: 8.561%; top: 75.351%;">动态规划</span>
</a>
<a href="chapter_greedy/">
@ -73,25 +65,20 @@
<!-- heading -->
<div class="heading-div">
<img style="height: min(9vh, 12vw);"
src="https://readme-typing-svg.demolab.com/?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=FFF&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+%E7%AE%97%E6%B3%95+!"
alt="" />
<img style="height: min(9vh, 12vw);" src="https://readme-typing-svg.demolab.com/?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=FFF&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+%E7%AE%97%E6%B3%95+!" alt="" />
<div style="pointer-events: auto;">
<p style="margin-top: max(-1vh, -2vw); margin-bottom: min(2vh, 3.5vw);">
动画图解、一键运行的数据结构与算法教程
</p>
<a href="chapter_hello_algo/" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path
d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" />
</svg>
<span>开始阅读</span>
</a>
<a href="https://github.com/krahets/hello-algo" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512">
<path
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z">
<path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z">
</path>
</svg>
<span>代码仓库</span>
@ -99,10 +86,8 @@
</div>
<!-- arrow -->
<div style="text-align: center; margin-top: min(2.5vh, 3.5vw);">
<svg xmlns="http://www.w3.org/2000/svg" fill="var(--md-default-fg-color)" height="2vh"
viewBox="0 0 384 512">
<path
d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
<svg xmlns="http://www.w3.org/2000/svg" fill="var(--md-default-fg-color)" height="2vh" viewBox="0 0 384 512">
<path d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
</svg>
</div>
</div>
@ -148,8 +133,7 @@
<div class="text-button">
<span>获取纸质书</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -162,8 +146,7 @@
<div class="text-button">
<span>在线阅读</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -174,8 +157,7 @@
<div class="text-button">
<span>下载 PDF</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -209,8 +191,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z" />
<path fill="var(--md-primary-bg-color)" d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z" />
</svg>
<h3 style="margin-left: 0.5em;">动画图解</h3>
</div>
@ -227,8 +208,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
<path fill="var(--md-primary-bg-color)" d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
</svg>
<h3 style="margin-left: 0.5em;">一键运行</h3>
</div>
@ -243,8 +223,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z" />
<path fill="var(--md-primary-bg-color)" d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z" />
</svg>
<h3 style="margin-left: 0.5em;">互助学习</h3>
</div>
@ -280,16 +259,14 @@
<div class="profile-div">
<div class="profile-cell">
<a href="https://github.com/codingonion">
<img class="profile-img" src="assets/avatar/avatar_codingonion.jpg"
alt="Reviewer: codingonion" />
<img class="profile-img" src="assets/avatar/avatar_codingonion.jpg" alt="Reviewer: codingonion" />
<br><b>codingonion</b>
<br><sub>Zig, Rust</sub>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/curtishd">
<img class="profile-img" src="assets/avatar/avatar_curtishd.jpg"
alt="Reviewer: curtishd" />
<img class="profile-img" src="assets/avatar/avatar_curtishd.jpg" alt="Reviewer: curtishd" />
<br><b>curtishd</b>
<br><sub>Kotlin</sub>
</a>
@ -338,8 +315,7 @@
</div>
<div class="profile-cell">
<a href="https://github.com/night-cruise">
<img class="profile-img" src="assets/avatar/avatar_night-cruise.jpg"
alt="Reviewer: night-cruise" />
<img class="profile-img" src="assets/avatar/avatar_night-cruise.jpg" alt="Reviewer: night-cruise" />
<br><b>night-cruise</b>
<br><sub>Rust</sub>
</a>
@ -373,8 +349,7 @@
<h3>贡献者</h3>
<p>本书在开源社区一百多位贡献者的共同努力下不断完善,感谢他们付出的时间与精力!</p>
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors"
style="width: 100%; max-width: 38.5em;">
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors" style="width: 100%; max-width: 38.5em;">
</a>
</div>
</div>

View File

@ -7,6 +7,8 @@ We are working on translating "Hello Algo" from Chinese to English with the foll
3. **Pull request review**: The optimized translation will be double checked by the reviewers through GitHub pull request workflow.
4. Repeat steps `2.` and `3.` for further improvements.
<img width="650" alt="translation_pipeline" src="https://github.com/user-attachments/assets/201930ef-723e-4179-b670-e5a084a8211e">
## Join us
We're seeking contributors who meet the following criteria.
@ -20,7 +22,10 @@ That is, our contributors are computer scientists, engineers, and students from
- **Native Chinese with professional working English**: Ensuring translation accuracy and consistency between CN and EN versions.
- **Native English**: Enhance the authenticity and fluency of the English content to flow naturally and to be engaging.
Don't hesitate to join us via WeChat `krahets-jyd` or on [Discord](https://discord.gg/nvspS56295)!
> [!note]
> If you are interested in joining us, don't hesitate to contact me via krahetx@gmail.com or WeChat `krahets-jyd`.
>
> We use this [Notion page](https://hello-algo.notion.site/chinese-to-english) to track progress and assign tasks. Please visit it for more details.
## Translation process

View File

@ -4,6 +4,6 @@
!!! abstract
Searching is an unknown adventure, where we may need to traverse every corner of a mysterious space, or perhaps quickly pinpoint our target.
Searching is an adventure into the unknown; where we may need to traverse every corner of a mysterious space, or perhaps well quickly locate our target.
In this journey of discovery, each exploration may yield an unexpected answer.
On this journey of discovery, each exploration may end up with an unexpected answer.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,8 +1,8 @@
# Summary
- Binary search depends on the order of data and performs the search by iteratively halving the search interval. It requires the input data to be sorted and is only applicable to arrays or array-based data structures.
- Brute force search locates data by traversing the data structure. Linear search is suitable for arrays and linked lists, while breadth-first search and depth-first search are suitable for graphs and trees. These algorithms are highly versatile, requiring no preprocessing of data, but have a higher time complexity of $O(n)$.
- Hash search, tree search, and binary search are efficient searching methods, capable of quickly locating target elements in specific data structures. These algorithms are highly efficient, with time complexities reaching $O(\log n)$ or even $O(1)$, but they usually require additional data structures.
- In practice, we need to analyze factors such as data volume, search performance requirements, data query and update frequencies, etc., to choose the appropriate search method.
- Linear search is suitable for small or frequently updated data; binary search is suitable for large, sorted data; hash search is suitable for scenarios requiring high query efficiency without the need for range queries; tree search is appropriate for large dynamic data that needs to maintain order and support range queries.
- Replacing linear search with hash search is a common strategy to optimize runtime, reducing the time complexity from $O(n)$ to $O(1)$.
- Brute force search may be required to locate an entry in an unordered dataset. Different search algorithms can be applied based on the data structure: Linear search is suitable for arrays and linked lists, while breadth-first search (BFS) and depth-first search (DFS) are suitable for graphs and trees. These algorithms are highly versatile, requiring no preprocessing of data, but they have a higher time complexity of $O(n)$.
- Hash search, tree search, and binary search are efficient search methods that can quickly locate target elements within specific data structures. These algorithms are highly efficient, with time complexities reaching $O(\log n)$ or even $O(1)$, but they usually require extra space to accommodate additional data structures.
- In practice, we need to analyze factors such as data volume, search performance requirements, data query and update frequencies, etc., to choose an appropriate search method.
- Linear search is ideal for small or frequently updated (volatile) data. Binary search works well for large and sorted data. Hash search is suitable for data that requires high query efficiency and does not need range queries. Tree search is best suited for large dynamic data that require maintaining order and need to support range queries.
- Replacing linear search with hash search is a common strategy to optimize runtime performance, reducing the time complexity from $O(n)$ to $O(1)$.

View File

@ -1,6 +1,6 @@
# Binary tree
A <u>binary tree</u> is a non-linear data structure that represents the hierarchical relationship between ancestors and descendants, embodying the divide-and-conquer logic of "splitting into two". Similar to a linked list, the basic unit of a binary tree is a node, each containing a value, a reference to the left child node, and a reference to the right child node.
A <u>binary tree</u> is a non-linear data structure that represents the hierarchical relationship between ancestors and descendants and embodies the divide-and-conquer logic of "splitting into two". Similar to a linked list, the basic unit of a binary tree is a node, and each node contains a value, a reference to its left child node, and a reference to its right child node.
=== "Python"
@ -198,9 +198,9 @@ A <u>binary tree</u> is a non-linear data structure that represents the hierarch
```
Each node has two references (pointers), pointing to the <u>left-child node</u> and <u>right-child node</u>, respectively. This node is called the <u>parent node</u> of these two child nodes. When given a node of a binary tree, we call the tree formed by this node's left child and all nodes under it the <u>left subtree</u> of this node. Similarly, the <u>right subtree</u> can be defined.
Each node has two references (pointers), pointing respectively to the <u>left-child node</u> and <u>right-child node</u>. This node is called the <u>parent node</u> of these two child nodes. When given a node of a binary tree, we call the tree formed by this node's left child and all nodes below it the <u>left subtree</u> of this node. Similarly, the <u>right subtree</u> can be defined.
**In a binary tree, except for leaf nodes, all other nodes contain child nodes and non-empty subtrees.** As shown in the figure below, if "Node 2" is considered as the parent node, then its left and right child nodes are "Node 4" and "Node 5," respectively. The left subtree is "the tree formed by Node 4 and all nodes under it," and the right subtree is "the tree formed by Node 5 and all nodes under it."
**In a binary tree, except leaf nodes, all other nodes contain child nodes and non-empty subtrees.** As shown in the figure below, if "Node 2" is regarded as a parent node, its left and right child nodes are "Node 4" and "Node 5" respectively. The left subtree is formed by "Node 4" and all nodes beneath it, while the right subtree is formed by "Node 5" and all nodes beneath it.
![Parent Node, child Node, subtree](binary_tree.assets/binary_tree_definition.png)
@ -208,26 +208,26 @@ Each node has two references (pointers), pointing to the <u>left-child node</u>
The commonly used terminology of binary trees is shown in the figure below.
- <u>Root node</u>: The node at the top level of the binary tree, which has no parent node.
- <u>Leaf node</u>: A node with no children, both of its pointers point to `None`.
- <u>Edge</u>: The line segment connecting two nodes, i.e., node reference (pointer).
- The <u>level</u> of a node: Incrementing from top to bottom, with the root node's level being 1.
- The <u>degree</u> of a node: The number of children a node has. In a binary tree, the degree can be 0, 1, or 2.
- The <u>height</u> of a binary tree: The number of edges passed from the root node to the farthest leaf node.
- The <u>depth</u> of a node: The number of edges passed from the root node to the node.
- <u>Root node</u>: The node at the top level of a binary tree, which does not have a parent node.
- <u>Leaf node</u>: A node that does not have any child nodes, with both of its pointers pointing to `None`.
- <u>Edge</u>: A line segment that connects two nodes, representing a reference (pointer) between the nodes.
- The <u>level</u> of a node: It increases from top to bottom, with the root node being at level 1.
- The <u>degree</u> of a node: The number of child nodes that a node has. In a binary tree, the degree can be 0, 1, or 2.
- The <u>height</u> of a binary tree: The number of edges from the root node to the farthest leaf node.
- The <u>depth</u> of a node: The number of edges from the root node to the node.
- The <u>height</u> of a node: The number of edges from the farthest leaf node to the node.
![Common Terminology of Binary Trees](binary_tree.assets/binary_tree_terminology.png)
!!! tip
Please note that we typically define "height" and "depth" as "the number of edges traversed", but some problems or textbooks may define them as "the number of nodes traversed". In such cases, both height and depth need to be incremented by 1.
Please note that we usually define "height" and "depth" as "the number of edges traversed", but some questions or textbooks may define them as "the number of nodes traversed". In this case, both height and depth need to be incremented by 1.
## Basic operations of binary trees
### Initializing a binary tree
Similar to a linked list, begin by initialize nodes, then construct references (pointers).
Similar to a linked list, the initialization of a binary tree involves first creating the nodes and then establishing the references (pointers) between them.
=== "Python"
@ -609,13 +609,13 @@ Similar to a linked list, inserting and removing nodes in a binary tree can be a
!!! tip
It's important to note that inserting nodes may change the original logical structure of the binary tree, while removing nodes typically involves removing the node and all its subtrees. Therefore, in a binary tree, insertion and removal are usually performed through a coordinated set of operations to achieve meaningful outcomes.
It should be noted that inserting nodes may change the original logical structure of the binary tree, while removing nodes typically involves removing the node and all its subtrees. Therefore, in a binary tree, insertion and removal are usually performed through a set of operations to achieve meaningful outcomes.
## Common types of binary trees
### Perfect binary tree
As shown in the figure below, in a <u>perfect binary tree</u>, all levels of nodes are fully filled. In a perfect binary tree, the degree of leaf nodes is $0$, while the degree of all other nodes is $2$; if the tree's height is $h$, then the total number of nodes is $2^{h+1} - 1$, showing a standard exponential relationship, reflecting the common phenomenon of cell division in nature.
As shown in the figure below, in a <u>perfect binary tree</u>, all levels are completely filled with nodes. In a perfect binary tree, leaf nodes have a degree of $0$, while all other nodes have a degree of $2$. The total number of nodes can be calculated as $2^{h+1} - 1$, where $h$ is the height of the tree. This exhibits a standard exponential relationship, reflecting the common phenomenon of cell division in nature.
!!! tip
@ -625,19 +625,19 @@ As shown in the figure below, in a <u>perfect binary tree</u>, all levels of nod
### Complete binary tree
As shown in the figure below, a <u>complete binary tree</u> has only the bottom level nodes not fully filled, and the bottom level nodes are filled as far left as possible.
As shown in the figure below, a <u>complete binary tree</u> is a binary tree where only the nodes in the bottom level are not completely filled, and the nodes in the bottom level are filled from left to right as much as possible. Please note that a perfect binary tree is also a complete binary tree.
![Complete binary tree](binary_tree.assets/complete_binary_tree.png)
### Full binary tree
As shown in the figure below, a <u>full binary tree</u> has all nodes except leaf nodes having two children.
As shown in the figure below, a <u>full binary tree</u>, except for the leaf nodes, has two child nodes for all other nodes.
![Full binary tree](binary_tree.assets/full_binary_tree.png)
### Balanced binary tree
As shown in the figure below, in a <u>balanced binary tree</u>, the absolute difference in height between the left and right subtrees of any node does not exceed 1.
As shown in the figure below, in a <u>balanced binary tree</u>, the absolute difference between the height of the left and right subtrees of any node does not exceed 1.
![Balanced binary tree](binary_tree.assets/balanced_binary_tree.png)
@ -645,12 +645,12 @@ As shown in the figure below, in a <u>balanced binary tree</u>, the absolute dif
The figure below shows the ideal and degenerate structures of binary trees. A binary tree becomes a "perfect binary tree" when every level is filled; while it degenerates into a "linked list" when all nodes are biased toward one side.
- The perfect binary tree is the ideal situation, fully leveraging the "divide and conquer" advantage of binary trees.
- A linked list is another extreme, where operations become linear, degrading the time complexity to $O(n)$.
- A perfect binary tree is an ideal scenario where the "divide and conquer" advantage of a binary tree can be fully utilized.
- On the other hand, a linked list represents another extreme where all operations become linear, resulting in a time complexity of $O(n)$.
![The Best and Worst Structures of Binary Trees](binary_tree.assets/binary_tree_best_worst_cases.png)
As shown in the table below, in the best and worst structures, the number of leaf nodes, total number of nodes, and height of the binary tree reach their maximum or minimum values.
As shown in the table below, in the best and worst structures, the binary tree achieves either maximum or minimum values for leaf node count, total number of nodes, and height.
<p align="center"> Table <id> &nbsp; The Best and Worst Structures of Binary Trees </p>

View File

@ -1,30 +1,24 @@
<!--Section: hero -->
<section data-md-color-scheme="slate" data-md-color-primary="grey" class="home-div"
style="height: min(100vh, 120vw); position: relative; margin-top:-2.4rem; padding: 0; overflow: hidden;">
<!-- Section: hero -->
<section data-md-color-scheme="slate" data-md-color-primary="grey" class="home-div" style="height: min(100vh, 120vw); position: relative; margin-top:-2.4rem; padding: 0; overflow: hidden;">
<!-- hero image -->
<img src="../assets/hero/universe_bg.png" class="hero-bg" alt="">
<div class="hero-div">
<img src="../assets/hero/ground.png" alt=""
style="position: absolute; width: auto; height: 26.445%; left: 28.211%; top: 54.145%;">
<img src="../assets/hero/links.png" alt=""
style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
<img src="../assets/hero/ground.png" alt="" style="position: absolute; width: auto; height: 26.445%; left: 28.211%; top: 54.145%;">
<img src="../assets/hero/links.png" alt="" style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
<a href="chapter_introduction/">
<img src="../assets/hero/astronaut.png" alt="" style="height: 46.673%; left: 35.413%; top: 24.343%;">
<span style="left: 52.744%; top: 22.319%;">Encounter with Algorithms</span>
</a>
<a href="chapter_computational_complexity/">
<img src="../assets/hero/chapter_computational_complexity.png" alt=""
style="height: 12.347%; left: 36.267%; top: 37.653%;">
<img src="../assets/hero/chapter_computational_complexity.png" alt="" style="height: 12.347%; left: 36.267%; top: 37.653%;">
<span style="left: 40.244%; top: 33.919%;">Complexity analysis</span>
</a>
<a href="chapter_array_and_linkedlist/">
<img src="../assets/hero/chapter_array_and_linkedlist.png" alt=""
style="height: 22.242%; left: 73.242%; top: 52.481%;">
<img src="../assets/hero/chapter_array_and_linkedlist.png" alt="" style="height: 22.242%; left: 73.242%; top: 52.481%;">
<span style="left: 90.897%; top: 76.259%;">Array and linked list</span>
</a>
<a href="chapter_stack_and_queue/">
<img src="../assets/hero/chapter_stack_and_queue.png" alt=""
style="height: 14.302%; left: 62.646%; top: 77.875%;">
<img src="../assets/hero/chapter_stack_and_queue.png" alt="" style="height: 14.302%; left: 62.646%; top: 77.875%;">
<span style="left: 80.071%; top: 88.25%;">Stack and queue</span>
</a>
<a href="chapter_hashing/">
@ -52,8 +46,7 @@
<span style="left: 28.805%; top: 53.808%;">Sorting</span>
</a>
<a href="chapter_divide_and_conquer/">
<img src="../assets/hero/chapter_divide_and_conquer.png" alt=""
style="height: 18.681%; left: 32.721%; top: 4.816%;">
<img src="../assets/hero/chapter_divide_and_conquer.png" alt="" style="height: 18.681%; left: 32.721%; top: 4.816%;">
<span style="left: 29.42%; top: 6.679%;">Divide and conquer</span>
</a>
<a href="chapter_backtracking/">
@ -61,8 +54,7 @@
<span style="left: 4.742%; top: 50.113%;">Backtracking</span>
</a>
<a href="chapter_dynamic_programming/">
<img src="../assets/hero/chapter_dynamic_programming.png" alt=""
style="height: 15.47%; left: 9.406%; top: 57.472%;">
<img src="../assets/hero/chapter_dynamic_programming.png" alt="" style="height: 15.47%; left: 9.406%; top: 57.472%;">
<span style="left: 8.561%; top: 75.351%;">Dynamic programming</span>
</a>
<a href="chapter_greedy/">
@ -73,25 +65,20 @@
<!-- heading -->
<div class="heading-div">
<img style="height: min(9vh, 12vw);"
src="https://readme-typing-svg.demolab.com?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=21C8B8&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+Algo+!"
alt="" />
<img style="height: min(9vh, 12vw);" src="https://readme-typing-svg.demolab.com?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=21C8B8&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+Algo+!" alt="" />
<div style="pointer-events: auto;">
<p style="margin-top: max(-1vh, -2vw); margin-bottom: min(2vh, 3.5vw);">
Data structures and algorithms crash course with animated illustrations and off-the-shelf code
</p>
<a href="chapter_hello_algo/" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path
d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" />
</svg>
<span>Dive in</span>
</a>
<a href="https://github.com/krahets/hello-algo" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512">
<path
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z">
<path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z">
</path>
</svg>
<span>GitHub</span>
@ -99,10 +86,8 @@
</div>
<!-- arrow -->
<div style="text-align: center; margin-top: min(2.5vh, 3.5vw);">
<svg xmlns="http://www.w3.org/2000/svg" fill="var(--md-default-fg-color)" height="2vh"
viewBox="0 0 384 512">
<path
d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
<svg xmlns="http://www.w3.org/2000/svg" fill="var(--md-default-fg-color)" height="2vh" viewBox="0 0 384 512">
<path d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
</svg>
</div>
</div>
@ -148,8 +133,7 @@
<div class="text-button">
<span>Paperbook</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -162,8 +146,7 @@
<div class="text-button">
<span>Read online</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -174,8 +157,7 @@
<div class="text-button">
<span>Download PDF</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -209,8 +191,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z" />
<path fill="var(--md-primary-bg-color)" d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z" />
</svg>
<h3 style="margin-left: 0.5em;">Animated illustrations</h3>
</div>
@ -227,8 +208,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
<path fill="var(--md-primary-bg-color)" d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
</svg>
<h3 style="margin-left: 0.5em;">Off-the-shelf code</h3>
</div>
@ -243,8 +223,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z" />
<path fill="var(--md-primary-bg-color)" d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z" />
</svg>
<h3 style="margin-left: 0.5em;">Learning together</h3>
</div>
@ -280,16 +259,14 @@
<div class="profile-div">
<div class="profile-cell">
<a href="https://github.com/codingonion">
<img class="profile-img" src="../assets/avatar/avatar_codingonion.jpg"
alt="Reviewer: codingonion" />
<img class="profile-img" src="../assets/avatar/avatar_codingonion.jpg" alt="Reviewer: codingonion" />
<br><b>codingonion</b>
<br><sub>Zig, Rust</sub>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/curtishd">
<img class="profile-img" src="../assets/avatar/avatar_curtishd.jpg"
alt="Reviewer: curtishd" />
<img class="profile-img" src="../assets/avatar/avatar_curtishd.jpg" alt="Reviewer: curtishd" />
<br><b>curtishd</b>
<br><sub>Kotlin</sub>
</a>
@ -338,8 +315,7 @@
</div>
<div class="profile-cell">
<a href="https://github.com/night-cruise">
<img class="profile-img" src="../assets/avatar/avatar_night-cruise.jpg"
alt="Reviewer: night-cruise" />
<img class="profile-img" src="../assets/avatar/avatar_night-cruise.jpg" alt="Reviewer: night-cruise" />
<br><b>night-cruise</b>
<br><sub>Rust</sub>
</a>
@ -374,71 +350,61 @@
<div class="profile-div">
<div class="profile-cell">
<a href="https://github.com/yuelinxin">
<img class="profile-img" src="../assets/avatar/avatar_yuelinxin.jpg"
alt="Reviewer: yuelinxin" />
<img class="profile-img" src="../assets/avatar/avatar_yuelinxin.jpg" alt="Reviewer: yuelinxin" />
<br><b>yuelinxin</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/K3v123">
<img class="profile-img" src="../assets/avatar/avatar_K3v123.jpg"
alt="Reviewer: K3v123" />
<img class="profile-img" src="../assets/avatar/avatar_K3v123.jpg" alt="Reviewer: K3v123" />
<br><b>K3v123</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/QiLOL">
<img class="profile-img" src="../assets/avatar/avatar_QiLOL.jpg"
alt="Reviewer: QiLOL" />
<img class="profile-img" src="../assets/avatar/avatar_QiLOL.jpg" alt="Reviewer: QiLOL" />
<br><b>QiLOL</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/Phoenix0415">
<img class="profile-img" src="../assets/avatar/avatar_Phoenix0415.jpg"
alt="Reviewer: Phoenix0415" />
<img class="profile-img" src="../assets/avatar/avatar_Phoenix0415.jpg" alt="Reviewer: Phoenix0415" />
<br><b>Phoenix0415</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/SamJin98">
<img class="profile-img" src="../assets/avatar/avatar_SamJin98.jpg"
alt="Reviewer: SamJin98" />
<img class="profile-img" src="../assets/avatar/avatar_SamJin98.jpg" alt="Reviewer: SamJin98" />
<br><b>SamJin98</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/yanedie">
<img class="profile-img" src="../assets/avatar/avatar_yanedie.jpg"
alt="Reviewer: yanedie" />
<img class="profile-img" src="../assets/avatar/avatar_yanedie.jpg" alt="Reviewer: yanedie" />
<br><b>yanedie</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/RafaelCaso">
<img class="profile-img" src="../assets/avatar/avatar_RafaelCaso.jpg"
alt="Reviewer: RafaelCaso" />
<img class="profile-img" src="../assets/avatar/avatar_RafaelCaso.jpg" alt="Reviewer: RafaelCaso" />
<br><b>RafaelCaso</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/pengchzn">
<img class="profile-img" src="../assets/avatar/avatar_pengchzn.jpg"
alt="Reviewer: pengchzn" />
<img class="profile-img" src="../assets/avatar/avatar_pengchzn.jpg" alt="Reviewer: pengchzn" />
<br><b>pengchzn</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/thomasq0">
<img class="profile-img" src="../assets/avatar/avatar_thomasq0.jpg"
alt="Reviewer: thomasq0" />
<img class="profile-img" src="../assets/avatar/avatar_thomasq0.jpg" alt="Reviewer: thomasq0" />
<br><b>thomasq0</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/magentaqin">
<img class="profile-img" src="../assets/avatar/avatar_magentaqin.jpg"
alt="Reviewer: magentaqin" />
<img class="profile-img" src="../assets/avatar/avatar_magentaqin.jpg" alt="Reviewer: magentaqin" />
<br><b>magentaqin</b>
</a>
</div>
@ -448,10 +414,9 @@
<!-- contributors -->
<div style="margin: 2em auto;">
<h3>Contributors</h3>
<p>This book has been enhanced through the collaborative efforts of more than 100 contributors. Thanks for their invaluable time and input!</p>
<p>This book has been optimized by the efforts of over 180 contributors. We sincerely thank them for their invaluable time and contributions!</p>
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors"
style="width: 100%; max-width: 38.5em;">
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors" style="width: 100%; max-width: 38.5em;">
</a>
</div>
</div>

View File

@ -37,12 +37,12 @@ HashTable *find(HashTable *h, int key) {
}
/* 雜湊表元素插入 */
void insert(HashTable *h, int key, int val) {
HashTable *t = find(h, key);
void insert(HashTable **h, int key, int val) {
HashTable *t = find(*h, key);
if (t == NULL) {
HashTable *tmp = malloc(sizeof(HashTable));
tmp->key = key, tmp->val = val;
HASH_ADD_INT(h, key, tmp);
HASH_ADD_INT(*h, key, tmp);
} else {
t->val = val;
}
@ -59,7 +59,7 @@ int *twoSumHashTable(int *nums, int numsSize, int target, int *returnSize) {
*returnSize = 2;
return res;
}
insert(hashtable, nums[i], i);
insert(&hashtable, nums[i], i);
}
*returnSize = 0;
return NULL;
@ -83,4 +83,4 @@ int main() {
printArray(res, returnSize);
return 0;
}
}

View File

@ -65,6 +65,7 @@ void countingSort(int nums[], int size) {
// 使用結果陣列 res 覆蓋原陣列 nums
memcpy(nums, res, size * sizeof(int));
// 5. 釋放記憶體
free(res);
free(counter);
}

View File

@ -16,6 +16,7 @@ int digit(int num, int exp) {
void countingSortDigit(int nums[], int size, int exp) {
// 十進位制的位範圍為 0~9 ,因此需要長度為 10 的桶陣列
int *counter = (int *)malloc((sizeof(int) * 10));
memset(counter, 0, sizeof(int) * 10); // 初始化為 0 以支持後續記憶體釋放
// 統計 0~9 各數字的出現次數
for (int i = 0; i < size; i++) {
// 獲取 nums[i] 第 k 位,記為 d
@ -39,13 +40,16 @@ void countingSortDigit(int nums[], int size, int exp) {
for (int i = 0; i < size; i++) {
nums[i] = res[i];
}
// 釋放記憶體
free(res);
free(counter);
}
/* 基數排序 */
void radixSort(int nums[], int size) {
// 獲取陣列的最大元素,用於判斷最大位數
int max = INT32_MIN;
for (size_t i = 0; i < size - 1; i++) {
for (int i = 0; i < size; i++) {
if (nums[i] > max) {
max = nums[i];
}

View File

@ -105,7 +105,7 @@ public class min_path_sum {
// 暴力搜尋
int res = MinPathSumDFS(grid, n - 1, m - 1);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
// 記憶化搜尋
int[][] mem = new int[n][];
@ -114,14 +114,14 @@ public class min_path_sum {
Array.Fill(mem[i], -1);
}
res = MinPathSumDFSMem(grid, mem, n - 1, m - 1);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
// 動態規劃
res = MinPathSumDP(grid);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
// 空間最佳化後的動態規劃
res = MinPathSumDPComp(grid);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
Console.WriteLine("從左上角到右下角的小路徑和為 " + res);
}
}

View File

@ -24,8 +24,8 @@ public class heap {
/* 初始化堆積 */
// 初始化小頂堆積
PriorityQueue<int, int> minHeap = new();
// 初始化大頂堆積(使用 lambda 表示式修改 Comparator 即可)
PriorityQueue<int, int> maxHeap = new(Comparer<int>.Create((x, y) => y - x));
// 初始化大頂堆積(使用 lambda 表示式修改 Comparer 即可)
PriorityQueue<int, int> maxHeap = new(Comparer<int>.Create((x, y) => y.CompareTo(x)));
Console.WriteLine("以下測試樣例為大頂堆積");
/* 元素入堆積 */

View File

@ -103,18 +103,18 @@ void main() {
//
int res = minPathSumDFS(grid, n - 1, m - 1);
print("從左上角到右下角的小路徑和為 $res");
print("從左上角到右下角的小路徑和為 $res");
//
List<List<int>> mem = List.generate(n, (i) => List.filled(m, -1));
res = minPathSumDFSMem(grid, mem, n - 1, m - 1);
print("從左上角到右下角的小路徑和為 $res");
print("從左上角到右下角的小路徑和為 $res");
//
res = minPathSumDP(grid);
print("從左上角到右下角的小路徑和為 $res");
print("從左上角到右下角的小路徑和為 $res");
//
res = minPathSumDPComp(grid);
print("從左上角到右下角的小路徑和為 $res");
print("從左上角到右下角的小路徑和為 $res");
}

View File

@ -20,7 +20,7 @@ func TestMinPathSum(t *testing.T) {
// 暴力搜尋
res := minPathSumDFS(grid, n-1, m-1)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
// 記憶化搜尋
mem := make([][]int, n)
@ -31,13 +31,13 @@ func TestMinPathSum(t *testing.T) {
}
}
res = minPathSumDFSMem(grid, mem, n-1, m-1)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
// 動態規劃
res = minPathSumDP(grid)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
// 空間最佳化後的動態規劃
res = minPathSumDPComp(grid)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
fmt.Printf("從左上角到右下角的小路徑和為 %d\n", res)
}

View File

@ -88,17 +88,17 @@ if __name__ == "__main__":
# 暴力搜尋
res = min_path_sum_dfs(grid, n - 1, m - 1)
print(f"從左上角到右下角的小路徑和為 {res}")
print(f"從左上角到右下角的小路徑和為 {res}")
# 記憶化搜尋
mem = [[-1] * m for _ in range(n)]
res = min_path_sum_dfs_mem(grid, mem, n - 1, m - 1)
print(f"從左上角到右下角的小路徑和為 {res}")
print(f"從左上角到右下角的小路徑和為 {res}")
# 動態規劃
res = min_path_sum_dp(grid)
print(f"從左上角到右下角的小路徑和為 {res}")
print(f"從左上角到右下角的小路徑和為 {res}")
# 空間最佳化後的動態規劃
res = min_path_sum_dp_comp(grid)
print(f"從左上角到右下角的小路徑和為 {res}")
print(f"從左上角到右下角的小路徑和為 {res}")

View File

@ -76,18 +76,18 @@ if __FILE__ == $0
# 暴力搜尋
res = min_path_sum_dfs(grid, n - 1, m - 1)
puts "從左上角到右下角的小路徑和為 #{res}"
puts "從左上角到右下角的小路徑和為 #{res}"
# 記憶化搜尋
mem = Array.new(n) { Array.new(m, - 1) }
res = min_path_sum_dfs_mem(grid, mem, n - 1, m -1)
puts "從左上角到右下角的小路徑和為 #{res}"
puts "從左上角到右下角的小路徑和為 #{res}"
# 動態規劃
res = min_path_sum_dp(grid)
puts "從左上角到右下角的小路徑和為 #{res}"
puts "從左上角到右下角的小路徑和為 #{res}"
# 空間最佳化後的動態規劃
res = min_path_sum_dp_comp(grid)
puts "從左上角到右下角的小路徑和為 #{res}"
puts "從左上角到右下角的小路徑和為 #{res}"
end

View File

@ -4,8 +4,7 @@
* Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use rand::Rng;
/* 隨機訪問元素 */

View File

@ -4,9 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use list_node::ListNode;
use hello_algo_rust::include::{print_util, ListNode};
use std::cell::RefCell;
use std::rc::Rc;

View File

@ -3,8 +3,7 @@
* Created Time: 2023-01-18
* Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* Driver Code */
fn main() {

View File

@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 串列類別 */
#[allow(dead_code)]

View File

@ -4,10 +4,8 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode};
use std::{cell::RefCell, rc::Rc};
use tree_node::{vec_to_tree, TreeNode};
/* 前序走訪:例題一 */
fn pre_order(res: &mut Vec<Rc<RefCell<TreeNode>>>, root: Option<&Rc<RefCell<TreeNode>>>) {

View File

@ -4,10 +4,8 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode};
use std::{cell::RefCell, rc::Rc};
use tree_node::{vec_to_tree, TreeNode};
/* 前序走訪:例題二 */
fn pre_order(

View File

@ -4,10 +4,8 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode};
use std::{cell::RefCell, rc::Rc};
use tree_node::{vec_to_tree, TreeNode};
/* 前序走訪:例題三 */
fn pre_order(

View File

@ -4,10 +4,8 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode};
use std::{cell::RefCell, rc::Rc};
use tree_node::{vec_to_tree, TreeNode};
/* 判斷當前狀態是否為解 */
fn is_solution(state: &mut Vec<Rc<RefCell<TreeNode>>>) -> bool {

View File

@ -4,13 +4,10 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use list_node::ListNode;
use hello_algo_rust::include::{print_util, ListNode, TreeNode};
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use tree_node::TreeNode;
/* 函式 */
fn function() -> i32 {

View File

@ -4,8 +4,7 @@
* Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use rand::seq::SliceRandom;
use rand::thread_rng;

View File

@ -4,10 +4,9 @@
* Author: codingonion (coderonion@gmail.com)
*/
use hello_algo_rust::include::{print_util, TreeNode};
use std::collections::HashMap;
use std::{cell::RefCell, rc::Rc};
include!("../include/include.rs");
use tree_node::TreeNode;
/* 構建二元樹:分治 */
fn dfs(

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/vertex.rs");
pub use hello_algo_rust::include::{vals_to_vets, vets_to_vals, Vertex};
use std::collections::HashMap;

View File

@ -4,9 +4,8 @@
* Author: WSL0809 (wslzzy@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::ListNode;
use crate::list_node::ListNode;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

View File

@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::collections::HashMap;

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::collections::BinaryHeap;

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 大頂堆積 */
struct MaxHeap {

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::cmp::Reverse;
use std::collections::BinaryHeap;

View File

@ -4,9 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use list_node::ListNode;
use hello_algo_rust::include::ListNode;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;

View File

@ -4,9 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use list_node::ListNode;
use hello_algo_rust::include::ListNode;
use std::cell::RefCell;
use std::rc::Rc;

View File

@ -4,8 +4,7 @@
* Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::collections::HashMap;
/* 方法一:暴力列舉 */

View File

@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 泡沫排序 */
fn bubble_sort(nums: &mut [i32]) {

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 桶排序 */
fn bucket_sort(nums: &mut [f64]) {

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 計數排序 */
// 簡單實現,無法用於排序物件

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 堆積的長度為 n ,從節點 i 開始,從頂至底堆積化 */
fn sift_down(nums: &mut [i32], n: usize, mut i: usize) {

View File

@ -4,7 +4,7 @@
* Author: xBLACKICEx (xBLACKICEx@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 插入排序 */
fn insertion_sort(nums: &mut [i32]) {

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 獲取元素 num 的第 k 位,其中 exp = 10^(k-1) */
fn digit(num: i32, exp: i32) -> usize {

View File

@ -4,7 +4,7 @@
* Author: WSL0809 (wslzzy@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 選擇排序 */
fn selection_sort(nums: &mut [i32]) {

View File

@ -3,9 +3,7 @@
* Created Time: 2023-03-11
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 基於環形陣列實現的雙向佇列 */
struct ArrayDeque {
nums: Vec<i32>, // 用於儲存雙向佇列元素的陣列

View File

@ -4,7 +4,7 @@
* Author: WSL0809 (wslzzy@outlook.com), codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* 基於陣列實現的堆疊 */
struct ArrayStack<T> {

View File

@ -4,8 +4,7 @@
* Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICEx@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::collections::VecDeque;
/* Driver Code */

View File

@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::cell::RefCell;
use std::rc::Rc;

View File

@ -4,9 +4,8 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, ListNode};
use list_node::ListNode;
use std::cell::RefCell;
use std::rc::Rc;

View File

@ -4,9 +4,8 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, ListNode};
use list_node::ListNode;
use std::cell::RefCell;
use std::rc::Rc;

View File

@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICEx@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::collections::VecDeque;

View File

@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
/* Driver Code */
pub fn main() {

View File

@ -4,7 +4,7 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, tree_node};
/* 陣列表示下的二元樹類別 */
struct ArrayBinaryTree {
@ -49,18 +49,11 @@ impl ArrayBinaryTree {
/* 層序走訪 */
fn level_order(&self) -> Vec<i32> {
let mut res = vec![];
// 直接走訪陣列
for i in 0..self.size() {
if let Some(val) = self.val(i) {
res.push(val)
}
}
res
self.tree.iter().filter_map(|&x| x).collect()
}
/* 深度優先走訪 */
fn dfs(&self, i: i32, order: &str, res: &mut Vec<i32>) {
fn dfs(&self, i: i32, order: &'static str, res: &mut Vec<i32>) {
if self.val(i).is_none() {
return;
}

View File

@ -4,12 +4,11 @@
* Author: night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, TreeNode};
use std::cell::RefCell;
use std::cmp::Ordering;
use std::rc::Rc;
use tree_node::TreeNode;
type OptionTreeNodeRc = Option<Rc<RefCell<TreeNode>>>;

View File

@ -4,13 +4,13 @@
* Author: xBLACKICEx (xBLACKICE@outlook.com)night-cruise (2586447362@qq.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::print_util;
use std::cell::RefCell;
use std::cmp::Ordering;
use std::rc::Rc;
use tree_node::TreeNode;
use hello_algo_rust::include::TreeNode;
type OptionTreeNodeRc = Option<Rc<RefCell<TreeNode>>>;
@ -126,7 +126,7 @@ impl BinarySearchTree {
// 刪除節點 cur
if !Rc::ptr_eq(&cur, self.root.as_ref().unwrap()) {
let left = pre.borrow().left.clone();
if left.is_some() && Rc::ptr_eq(&left.as_ref().unwrap(), &cur) {
if left.is_some() && Rc::ptr_eq(left.as_ref().unwrap(), &cur) {
pre.borrow_mut().left = child;
} else {
pre.borrow_mut().right = child;
@ -147,11 +147,11 @@ impl BinarySearchTree {
break;
}
}
let tmpval = tmp.unwrap().borrow().val;
let tmp_val = tmp.unwrap().borrow().val;
// 遞迴刪除節點 tmp
self.remove(tmpval);
self.remove(tmp_val);
// 用 tmp 覆蓋 cur
cur.borrow_mut().val = tmpval;
cur.borrow_mut().val = tmp_val;
}
}
}

View File

@ -4,8 +4,7 @@
* Author: xBLACKICEx (xBLACKICE@outlook.com)
*/
use std::rc::Rc;
include!("../include/include.rs");
use tree_node::TreeNode;
use hello_algo_rust::include::{print_util, TreeNode};
/* Driver Code */
fn main() {

View File

@ -4,11 +4,11 @@
* Author: xBLACKICEx (xBLACKICE@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode};
use hello_algo_rust::op_vec;
use std::collections::VecDeque;
use std::{cell::RefCell, rc::Rc};
use tree_node::{vec_to_tree, TreeNode};
/* 層序走訪 */
fn level_order(root: &Rc<RefCell<TreeNode>>) -> Vec<i32> {

View File

@ -4,22 +4,27 @@
* Author: xBLACKICEx (xBLACKICE@outlook.com)
*/
include!("../include/include.rs");
use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode};
use hello_algo_rust::op_vec;
use std::cell::RefCell;
use std::rc::Rc;
use tree_node::{vec_to_tree, TreeNode};
/* 前序走訪 */
fn pre_order(root: Option<&Rc<RefCell<TreeNode>>>) -> Vec<i32> {
let mut result = vec![];
if let Some(node) = root {
// 訪問優先順序:根節點 -> 左子樹 -> 右子樹
result.push(node.borrow().val);
result.extend(pre_order(node.borrow().left.as_ref()));
result.extend(pre_order(node.borrow().right.as_ref()));
fn dfs(root: Option<&Rc<RefCell<TreeNode>>>, res: &mut Vec<i32>) {
if let Some(node) = root {
// 訪問優先順序:根節點 -> 左子樹 -> 右子樹
let node = node.borrow();
res.push(node.val);
dfs(node.left.as_ref(), res);
dfs(node.right.as_ref(), res);
}
}
dfs(root, &mut result);
result
}
@ -27,12 +32,17 @@ fn pre_order(root: Option<&Rc<RefCell<TreeNode>>>) -> Vec<i32> {
fn in_order(root: Option<&Rc<RefCell<TreeNode>>>) -> Vec<i32> {
let mut result = vec![];
if let Some(node) = root {
// 訪問優先順序:左子樹 -> 根節點 -> 右子樹
result.extend(in_order(node.borrow().left.as_ref()));
result.push(node.borrow().val);
result.extend(in_order(node.borrow().right.as_ref()));
fn dfs(root: Option<&Rc<RefCell<TreeNode>>>, res: &mut Vec<i32>) {
if let Some(node) = root {
// 訪問優先順序:左子樹 -> 根節點 -> 右子樹
let node = node.borrow();
dfs(node.left.as_ref(), res);
res.push(node.val);
dfs(node.right.as_ref(), res);
}
}
dfs(root, &mut result);
result
}
@ -40,12 +50,18 @@ fn in_order(root: Option<&Rc<RefCell<TreeNode>>>) -> Vec<i32> {
fn post_order(root: Option<&Rc<RefCell<TreeNode>>>) -> Vec<i32> {
let mut result = vec![];
if let Some(node) = root {
// 訪問優先順序:左子樹 -> 右子樹 -> 根節點
result.extend(post_order(node.borrow().left.as_ref()));
result.extend(post_order(node.borrow().right.as_ref()));
result.push(node.borrow().val);
fn dfs(root: Option<&Rc<RefCell<TreeNode>>>, res: &mut Vec<i32>) {
if let Some(node) = root {
// 訪問優先順序:左子樹 -> 右子樹 -> 根節點
let node = node.borrow();
dfs(node.left.as_ref(), res);
dfs(node.right.as_ref(), res);
res.push(node.val);
}
}
dfs(root, &mut result);
result
}

View File

@ -0,0 +1,57 @@
/*
* File: list_node.rs
* Created Time: 2023-03-05
* Author: codingonion (coderonion@gmail.com), rongyi (hiarongyi@gmail.com)
*/
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
#[derive(Debug)]
pub struct ListNode<T> {
pub val: T,
pub next: Option<Rc<RefCell<ListNode<T>>>>,
}
impl<T> ListNode<T> {
pub fn new(val: T) -> Rc<RefCell<ListNode<T>>> {
Rc::new(RefCell::new(ListNode { val, next: None }))
}
/* 將陣列反序列化為鏈結串列 */
pub fn arr_to_linked_list(array: &[T]) -> Option<Rc<RefCell<ListNode<T>>>>
where
T: Copy + Clone,
{
let mut head = None;
// insert in reverse order
for item in array.iter().rev() {
let node = Rc::new(RefCell::new(ListNode {
val: *item,
next: head.take(),
}));
head = Some(node);
}
head
}
/* 將鏈結串列轉化為雜湊表 */
pub fn linked_list_to_hashmap(
linked_list: Option<Rc<RefCell<ListNode<T>>>>,
) -> HashMap<T, Rc<RefCell<ListNode<T>>>>
where
T: std::hash::Hash + Eq + Copy + Clone,
{
let mut hashmap = HashMap::new();
let mut node = linked_list;
while let Some(cur) = node {
let borrow = cur.borrow();
hashmap.insert(borrow.val.clone(), cur.clone());
node = borrow.next.clone();
}
hashmap
}
}

View File

@ -0,0 +1,16 @@
/*
* File: include.rs
* Created Time: 2023-02-05
* Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICE@outlook.com)
*/
pub mod list_node;
pub mod print_util;
pub mod tree_node;
pub mod vertex;
// rexport to include
pub use list_node::*;
pub use print_util::*;
pub use tree_node::*;
pub use vertex::*;

View File

@ -0,0 +1,103 @@
/*
* File: print_util.rs
* Created Time: 2023-02-05
* Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICEx@outlook.com)
*/
use std::cell::{Cell, RefCell};
use std::fmt::Display;
use std::collections::{HashMap, VecDeque};
use std::rc::Rc;
use super::list_node::ListNode;
use super::tree_node::{TreeNode, vec_to_tree};
struct Trunk<'a, 'b> {
prev: Option<&'a Trunk<'a, 'b>>,
str: Cell<&'b str>,
}
/* 列印陣列 */
pub fn print_array<T: Display>(nums: &[T]) {
print!("[");
if nums.len() > 0 {
for (i, num) in nums.iter().enumerate() {
print!("{}{}", num, if i == nums.len() - 1 {"]"} else {", "} );
}
} else {
print!("]");
}
}
/* 列印雜湊表 */
pub fn print_hash_map<TKey: Display, TValue: Display>(map: &HashMap<TKey, TValue>) {
for (key, value) in map {
println!("{key} -> {value}");
}
}
/* 列印佇列(雙向佇列) */
pub fn print_queue<T: Display>(queue: &VecDeque<T>) {
print!("[");
let iter = queue.iter();
for (i, data) in iter.enumerate() {
print!("{}{}", data, if i == queue.len() - 1 {"]"} else {", "} );
}
}
/* 列印鏈結串列 */
pub fn print_linked_list<T: Display>(head: &Rc<RefCell<ListNode<T>>>) {
print!("{}{}", head.borrow().val, if head.borrow().next.is_none() {"\n"} else {" -> "});
if let Some(node) = &head.borrow().next {
return print_linked_list(node);
}
}
/* 列印二元樹 */
pub fn print_tree(root: &Rc<RefCell<TreeNode>>) {
_print_tree(Some(root), None, false);
}
/* 列印二元樹 */
fn _print_tree(root: Option<&Rc<RefCell<TreeNode>>>, prev: Option<&Trunk>, is_right: bool) {
if let Some(node) = root {
let mut prev_str = " ";
let trunk = Trunk { prev, str: Cell::new(prev_str) };
_print_tree(node.borrow().right.as_ref(), Some(&trunk), true);
if prev.is_none() {
trunk.str.set("———");
} else if is_right {
trunk.str.set("/———");
prev_str = " |";
} else {
trunk.str.set("\\———");
prev.as_ref().unwrap().str.set(prev_str);
}
show_trunks(Some(&trunk));
println!(" {}", node.borrow().val);
if let Some(prev) = prev {
prev.str.set(prev_str);
}
trunk.str.set(" |");
_print_tree(node.borrow().left.as_ref(), Some(&trunk), false);
}
}
fn show_trunks(trunk: Option<&Trunk>) {
if let Some(trunk) = trunk {
show_trunks(trunk.prev);
print!("{}", trunk.str.get());
}
}
/* 列印堆積 */
pub fn print_heap(heap: Vec<i32>) {
println!("堆積的陣列表示:{:?}", heap);
println!("堆積的樹狀表示:");
if let Some(root) = vec_to_tree(heap.into_iter().map(|val| Some(val)).collect()) {
print_tree(&root);
}
}

View File

@ -0,0 +1,92 @@
/*
* File: tree_node.rs
* Created Time: 2023-02-27
* Author: xBLACKICEx (xBLACKICE@outlook.com), night-cruise (2586447362@qq.com)
*/
use std::cell::RefCell;
use std::rc::Rc;
/* 二元樹節點型別 */
#[derive(Debug)]
pub struct TreeNode {
pub val: i32,
pub height: i32,
pub parent: Option<Rc<RefCell<TreeNode>>>,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
/* 建構子 */
pub fn new(val: i32) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Self {
val,
height: 0,
parent: None,
left: None,
right: None,
}))
}
}
#[macro_export]
macro_rules! op_vec {
( $( $x:expr ),* ) => {
vec![
$( Option::from($x).map(|x| x) ),*
]
};
}
// 序列化編碼規則請參考:
// https://www.hello-algo.com/chapter_tree/array_representation_of_tree/
// 二元樹的陣列表示:
// [1, 2, 3, 4, None, 6, 7, 8, 9, None, None, 12, None, None, 15]
// 二元樹的鏈結串列表示:
// /——— 15
// /——— 7
// /——— 3
// | \——— 6
// | \——— 12
// ——— 1
// \——— 2
// | /——— 9
// \——— 4
// \——— 8
/* 將串列反序列化為二元樹:遞迴 */
fn vec_to_tree_dfs(arr: &[Option<i32>], i: usize) -> Option<Rc<RefCell<TreeNode>>> {
if i >= arr.len() || arr[i].is_none() {
return None;
}
let root = TreeNode::new(arr[i].unwrap());
root.borrow_mut().left = vec_to_tree_dfs(arr, 2 * i + 1);
root.borrow_mut().right = vec_to_tree_dfs(arr, 2 * i + 2);
Some(root)
}
/* 將串列反序列化為二元樹 */
pub fn vec_to_tree(arr: Vec<Option<i32>>) -> Option<Rc<RefCell<TreeNode>>> {
vec_to_tree_dfs(&arr, 0)
}
/* 將二元樹序列化為串列:遞迴 */
fn tree_to_vec_dfs(root: Option<&Rc<RefCell<TreeNode>>>, i: usize, res: &mut Vec<Option<i32>>) {
if let Some(root) = root {
// i + 1 is the minimum valid size to access index i
while res.len() < i + 1 {
res.push(None);
}
res[i] = Some(root.borrow().val);
tree_to_vec_dfs(root.borrow().left.as_ref(), 2 * i + 1, res);
tree_to_vec_dfs(root.borrow().right.as_ref(), 2 * i + 2, res);
}
}
/* 將二元樹序列化為串列 */
pub fn tree_to_vec(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Option<i32>> {
let mut res = vec![];
tree_to_vec_dfs(root.as_ref(), 0, &mut res);
res
}

View File

@ -0,0 +1,21 @@
/*
* File: vertex.rs
* Created Time: 2023-07-13
* Author: night-cruise (2586447362@qq.com)
*/
/* 頂點型別 */
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct Vertex {
pub val: i32,
}
/* 輸入值串列 vals ,返回頂點串列 vets */
pub fn vals_to_vets(vals: Vec<i32>) -> Vec<Vertex> {
vals.into_iter().map(|val| Vertex { val }).collect()
}
/* 輸入頂點串列 vets ,返回值串列 vals */
pub fn vets_to_vals(vets: Vec<Vertex>) -> Vec<i32> {
vets.into_iter().map(|vet| vet.val).collect()
}

View File

@ -0,0 +1 @@
pub mod include;

View File

@ -105,19 +105,19 @@ enum MinPathSum {
//
var res = minPathSumDFS(grid: grid, i: n - 1, j: m - 1)
print("從左上角到右下角的小路徑和為 \(res)")
print("從左上角到右下角的小路徑和為 \(res)")
//
var mem = Array(repeating: Array(repeating: -1, count: m), count: n)
res = minPathSumDFSMem(grid: grid, mem: &mem, i: n - 1, j: m - 1)
print("從左上角到右下角的小路徑和為 \(res)")
print("從左上角到右下角的小路徑和為 \(res)")
//
res = minPathSumDP(grid: grid)
print("從左上角到右下角的小路徑和為 \(res)")
print("從左上角到右下角的小路徑和為 \(res)")
//
res = minPathSumDPComp(grid: grid)
print("從左上角到右下角的小路徑和為 \(res)")
print("從左上角到右下角的小路徑和為 \(res)")
}
}

View File

@ -157,8 +157,8 @@
/* 初始化堆積 */
// 初始化小頂堆積
PriorityQueue<int, int> minHeap = new();
// 初始化大頂堆積(使用 lambda 表示式修改 Comparator 即可)
PriorityQueue<int, int> maxHeap = new(Comparer<int>.Create((x, y) => y - x));
// 初始化大頂堆積(使用 lambda 表示式修改 Comparer 即可)
PriorityQueue<int, int> maxHeap = new(Comparer<int>.Create((x, y) => y.CompareTo(x)));
/* 元素入堆積 */
maxHeap.Enqueue(1, 1);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -180,7 +180,7 @@ AVL 樹既是二元搜尋樹,也是平衡二元樹,同時滿足這兩類二
```c title=""
/* AVL 樹節點結構體 */
TreeNode struct TreeNode {
typedef struct TreeNode {
int val;
int height;
struct TreeNode *left;

View File

@ -1,30 +1,24 @@
<!--Section: hero -->
<section data-md-color-scheme="slate" data-md-color-primary="grey" class="home-div"
style="height: min(100vh, 120vw); position: relative; margin-top:-2.4rem; padding: 0; overflow: hidden;">
<!-- Section: hero -->
<section data-md-color-scheme="slate" data-md-color-primary="grey" class="home-div" style="height: min(100vh, 120vw); position: relative; margin-top:-2.4rem; padding: 0; overflow: hidden;">
<!-- hero image -->
<img src="../assets/hero/universe_bg.png" class="hero-bg" alt="">
<div class="hero-div">
<img src="../assets/hero/ground.png" alt=""
style="position: absolute; width: auto; height: 26.445%; left: 28.211%; top: 54.145%;">
<img src="../assets/hero/links.png" alt=""
style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
<img src="../assets/hero/ground.png" alt="" style="position: absolute; width: auto; height: 26.445%; left: 28.211%; top: 54.145%;">
<img src="../assets/hero/links.png" alt="" style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
<a href="chapter_introduction/">
<img src="../assets/hero/astronaut.png" alt="" style="height: 46.673%; left: 35.413%; top: 24.343%;">
<span style="left: 52.244%; top: 20.919%;">初識演算法</span>
</a>
<a href="chapter_computational_complexity/">
<img src="../assets/hero/chapter_computational_complexity.png" alt=""
style="height: 12.347%; left: 36.267%; top: 37.653%;">
<img src="../assets/hero/chapter_computational_complexity.png" alt="" style="height: 12.347%; left: 36.267%; top: 37.653%;">
<span style="left: 39.244%; top: 33.919%;">複雜度</span>
</a>
<a href="chapter_array_and_linkedlist/">
<img src="../assets/hero/chapter_array_and_linkedlist.png" alt=""
style="height: 22.242%; left: 73.242%; top: 52.481%;">
<img src="../assets/hero/chapter_array_and_linkedlist.png" alt="" style="height: 22.242%; left: 73.242%; top: 52.481%;">
<span style="left: 90.897%; top: 76.259%;">陣列與鏈結串列</span>
</a>
<a href="chapter_stack_and_queue/">
<img src="../assets/hero/chapter_stack_and_queue.png" alt=""
style="height: 14.302%; left: 62.646%; top: 77.875%;">
<img src="../assets/hero/chapter_stack_and_queue.png" alt="" style="height: 14.302%; left: 62.646%; top: 77.875%;">
<span style="left: 77.571%; top: 91.25%;">堆疊與佇列</span>
</a>
<a href="chapter_hashing/">
@ -52,8 +46,7 @@
<span style="left: 28.805%; top: 53.808%;">排序</span>
</a>
<a href="chapter_divide_and_conquer/">
<img src="../assets/hero/chapter_divide_and_conquer.png" alt=""
style="height: 18.681%; left: 32.721%; top: 4.816%;">
<img src="../assets/hero/chapter_divide_and_conquer.png" alt="" style="height: 18.681%; left: 32.721%; top: 4.816%;">
<span style="left: 31.42%; top: 8.679%;">分治</span>
</a>
<a href="chapter_backtracking/">
@ -61,8 +54,7 @@
<span style="left: 4.742%; top: 50.113%;">回溯</span>
</a>
<a href="chapter_dynamic_programming/">
<img src="../assets/hero/chapter_dynamic_programming.png" alt=""
style="height: 15.47%; left: 9.406%; top: 57.472%;">
<img src="../assets/hero/chapter_dynamic_programming.png" alt="" style="height: 15.47%; left: 9.406%; top: 57.472%;">
<span style="left: 8.561%; top: 75.351%;">動態規劃</span>
</a>
<a href="chapter_greedy/">
@ -73,25 +65,20 @@
<!-- heading -->
<div class="heading-div">
<img style="height: min(9vh, 12vw);"
src="https://readme-typing-svg.demolab.com/?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=FFF&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+%E6%BC%94%E7%AE%97%E6%B3%95+!"
alt="" />
<img style="height: min(9vh, 12vw);" src="https://readme-typing-svg.demolab.com/?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=FFF&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+%E6%BC%94%E7%AE%97%E6%B3%95+!" alt="" />
<div style="pointer-events: auto;">
<p style="margin-top: max(-1vh, -2vw); margin-bottom: min(2vh, 3.5vw);">
動畫圖解、一鍵執行的資料結構與演算法教程
</p>
<a href="chapter_hello_algo/" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path
d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path d="M160 96a96 96 0 1 1 192 0A96 96 0 1 1 160 96zm80 152V512l-48.4-24.2c-20.9-10.4-43.5-17-66.8-19.3l-96-9.6C12.5 457.2 0 443.5 0 427V224c0-17.7 14.3-32 32-32H62.3c63.6 0 125.6 19.6 177.7 56zm32 264V248c52.1-36.4 114.1-56 177.7-56H480c17.7 0 32 14.3 32 32V427c0 16.4-12.5 30.2-28.8 31.8l-96 9.6c-23.2 2.3-45.9 8.9-66.8 19.3L272 512z" />
</svg>
<span>開始閱讀</span>
</a>
<a href="https://github.com/krahets/hello-algo" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512">
<path
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z">
<path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z">
</path>
</svg>
<span>程式碼倉庫</span>
@ -99,10 +86,8 @@
</div>
<!-- arrow -->
<div style="text-align: center; margin-top: min(2.5vh, 3.5vw);">
<svg xmlns="http://www.w3.org/2000/svg" fill="var(--md-default-fg-color)" height="2vh"
viewBox="0 0 384 512">
<path
d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
<svg xmlns="http://www.w3.org/2000/svg" fill="var(--md-default-fg-color)" height="2vh" viewBox="0 0 384 512">
<path d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
</svg>
</div>
</div>
@ -148,8 +133,7 @@
<div class="text-button">
<span>紙質書(簡中)</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -162,8 +146,7 @@
<div class="text-button">
<span>線上閱讀</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -174,8 +157,7 @@
<div class="text-button">
<span>PDF簡中</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
</div>
</a>
@ -209,8 +191,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z" />
<path fill="var(--md-primary-bg-color)" d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z" />
</svg>
<h3 style="margin-left: 0.5em;">動畫圖解</h3>
</div>
@ -227,8 +208,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
<path fill="var(--md-primary-bg-color)" d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
</svg>
<h3 style="margin-left: 0.5em;">一鍵執行</h3>
</div>
@ -243,8 +223,7 @@
<div>
<div style="display: flex; align-items: center;">
<svg xmlns="http://www.w3.org/2000/svg" height="1.5em" width="1.5em" viewBox="0 0 640 512">
<path fill="var(--md-primary-bg-color)"
d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z" />
<path fill="var(--md-primary-bg-color)" d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z" />
</svg>
<h3 style="margin-left: 0.5em;">互助學習</h3>
</div>
@ -280,16 +259,14 @@
<div class="profile-div">
<div class="profile-cell">
<a href="https://github.com/codingonion">
<img class="profile-img" src="../assets/avatar/avatar_codingonion.jpg"
alt="Reviewer: codingonion" />
<img class="profile-img" src="../assets/avatar/avatar_codingonion.jpg" alt="Reviewer: codingonion" />
<br><b>codingonion</b>
<br><sub>Zig, Rust</sub>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/curtishd">
<img class="profile-img" src="../assets/avatar/avatar_curtishd.jpg"
alt="Reviewer: curtishd" />
<img class="profile-img" src="../assets/avatar/avatar_curtishd.jpg" alt="Reviewer: curtishd" />
<br><b>curtishd</b>
<br><sub>Kotlin</sub>
</a>
@ -338,8 +315,7 @@
</div>
<div class="profile-cell">
<a href="https://github.com/night-cruise">
<img class="profile-img" src="../assets/avatar/avatar_night-cruise.jpg"
alt="Reviewer: night-cruise" />
<img class="profile-img" src="../assets/avatar/avatar_night-cruise.jpg" alt="Reviewer: night-cruise" />
<br><b>night-cruise</b>
<br><sub>Rust</sub>
</a>
@ -374,15 +350,13 @@
<div class="profile-div">
<div class="profile-cell">
<a href="https://github.com/Shyam-Chen">
<img class="profile-img" src="../assets/avatar/avatar_Shyam-Chen.jpg"
alt="Reviewer: Shyam-Chen" />
<img class="profile-img" src="../assets/avatar/avatar_Shyam-Chen.jpg" alt="Reviewer: Shyam-Chen" />
<br><b>Shyam-Chen</b>
</a>
</div>
<div class="profile-cell">
<a href="https://github.com/Dr-XYZ">
<img class="profile-img" src="../assets/avatar/avatar_Dr-XYZ.jpg"
alt="Reviewer: Dr-XYZ" />
<img class="profile-img" src="../assets/avatar/avatar_Dr-XYZ.jpg" alt="Reviewer: Dr-XYZ" />
<br><b>Dr-XYZ</b>
</a>
</div>
@ -394,8 +368,7 @@
<h3>貢獻者</h3>
<p>本書在開源社群一百多位貢獻者的共同努力下不斷完善,感謝他們付出的時間與精力!</p>
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors"
style="width: 100%; max-width: 38.5em;">
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors" style="width: 100%; max-width: 38.5em;">
</a>
</div>
</div>