<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Aryue的个人博客</title>
        <link>https://www.aryue.com</link>
        <description>email：578626935@qq.com</description>
        <lastBuildDate>Wed, 11 Nov 2026 16:18:25 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, Aryue</copyright>
        <item>
            <title><![CDATA[AutoGPT思路以及代码解读]]></title>
            <link>https://www.aryue.com/article/e0efe1e7-d050-4e30-afbb-cee11a247f21</link>
            <guid>https://www.aryue.com/article/e0efe1e7-d050-4e30-afbb-cee11a247f21</guid>
            <pubDate>Sat, 29 Apr 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[个人对AutoGPT的一些理解]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-e0efe1e7d0504e30afbbcee11a247f21"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-4128218d10a34458b60aae13d03a824e" data-id="4128218d10a34458b60aae13d03a824e"><span><div id="4128218d10a34458b60aae13d03a824e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4128218d10a34458b60aae13d03a824e" title="🤔AutoGPT思路以及代码解读"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤔AutoGPT思路以及代码解读</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-73ef5b7d44404195a380d83432251802" data-id="73ef5b7d44404195a380d83432251802"><span><div id="73ef5b7d44404195a380d83432251802" class="notion-header-anchor"></div><a class="notion-hash-link" href="#73ef5b7d44404195a380d83432251802" title="简介"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">简介</span></span></h3><div class="notion-text notion-block-3945a6709f954486be641d8e878211d9">官网链接：</div><div class="notion-text notion-block-cda4444f1a0b4f408df4cd4184329c13"><a class="notion-link" href="https://github.com/Torantulino/Auto-GPT" target="_blank" rel="noopener noreferrer">https://github.com/Torantulino/Auto-GPT</a></div><div class="notion-text notion-block-782dd001c6b343e9acea68ab354b2b2a">官网描述：</div><div class="notion-text notion-block-d426828c537340dbbdc58e758d0ca26b">Auto-GPT 是一个实验性的开源应用程序，展示了 GPT-4 语言模型的实力。该程序由 GPT-4 驱动，将 LLM 的“思想”链接在一起，以自主实现您设定的任何目标。作为 GPT-4 完全自主运行的首批示例之一，Auto-GPT 打破了 AI 的可能性界限。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-21f06507cfae4a5993860ed37b623d71"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A984d74c5-1c68-4ab7-8959-755af118b07a%3AUntitled.png?table=block&amp;id=21f06507-cfae-4a59-9386-0ed37b623d71&amp;t=21f06507-cfae-4a59-9386-0ed37b623d71" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-cd691c0726a54efb846864ef20a0c987">如上图，AutoGPT项目的火爆程度随着star的增长速度以指数级上升。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-200ca41485d94109b18872f6ee3d51cb"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:540.9874877929688px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Abd4b8ab5-c8ee-46a5-9afa-c39c0baab8f0%3AUntitled.png?table=block&amp;id=200ca414-85d9-4109-b188-72f6ee3d51cb&amp;t=200ca414-85d9-4109-b188-72f6ee3d51cb" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-d1b23639f24144e09258d90bb629bee4">就在笔者开始撰写本文时的8分钟前，项目仍在快速迭代，0.2.0版本刚刚发布。</div><hr class="notion-hr notion-block-61c482ddce36498bad0e7646b1ab861d"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-c298d951442f44da800f2fbeb9e57ee3" data-id="c298d951442f44da800f2fbeb9e57ee3"><span><div id="c298d951442f44da800f2fbeb9e57ee3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c298d951442f44da800f2fbeb9e57ee3" title="AutoGPT强在哪儿？和ChatGPT又有何本质的区别？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">AutoGPT强在哪儿？和ChatGPT又有何本质的区别？</span></span></h3><div class="notion-text notion-block-e3449d0cd48642a7964adc9a61515522">举个例子，ChatGPT是一个万事通的对话小助手。我们可以让他扮演各种角色，回答各个领域的问题，包括且不限于完成编写代码 👨‍💻、阅读论文、指导AI绘画等工作。</div><div class="notion-text notion-block-5b05d8939e704ebb8ea2db14d50ceb59">从交互方式的角度来看，ChatGPT是以人为主导，人类描述各种工作并让ChatGPT去工作。工作成果由人来验收，由人来给出工作完成质量的反馈。一次提问往往无法得到一个准确的结果，用户需要反复提问，修正错误，最后才能得到相对较好的答案。</div><div class="notion-text notion-block-10d9ef635d9c473f8cab3e1206f9a04c">对于AutoGPT而言，交互模式发生了本质的变化。我们设定了一个目标，让它自己去分析完成这项工作需要执行哪些步骤，为什么执行这些步骤，制定计划并自主思考。在最后一个步骤，它会去执行行动，行动的结果再重新输入回大脑，循环往复。AutoGPT正如其名，是一个“全自动”版本的GPT，基于GPT-4或GPT3.5开发，并扩展了自己的能力。就好比是让原来的ChatGPT作为思考的“大脑”，AutoGPT经过二次开发，让它拥有了能执行行动的“手”和“脚”。</div><div class="notion-text notion-block-3feaa6c2874f428f80e8042066fd4b97">下图是笔者在本机运行AutoGPT时执行的一个案例。我为它命名为“James”，让它分析今年NBA总决赛总冠军最有可能是哪支队伍，并将分析过程保存在word文档中。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-f2432e30aae24727805bef3b75a8f95a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ab02bf8b6-1afd-40ee-a3a0-126fea9d9151%3AUntitled.png?table=block&amp;id=f2432e30-aae2-4727-805b-ef3b75a8f95a&amp;t=f2432e30-aae2-4727-805b-ef3b75a8f95a" alt="AutoGPT运行示例" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">AutoGPT运行示例</figcaption></div></figure><div class="notion-text notion-block-0cb91116158f4b1585b7949eba6eb5c4">重点看那些有颜色高亮的文字，这些文字能直观地显示出 AutoGPT 的运行流程。</div><ul class="notion-list notion-list-disc notion-block-786363a3207f4b698e5e33b1907c4bcc"><li>James Thoughts：名为“James”的助手对当前目标进行思考的过程，思考的结果是为了制定工作计划。</li></ul><ul class="notion-list notion-list-disc notion-block-5a8baba794b2410fb5036063cc037c47"><li>Reasoning：给出工作计划合理性的理由，比如这里，AutoGPT 输出的内容是其针对“预测 NBA 总冠军”这一目标，要进行数据分析的理由。</li></ul><ul class="notion-list notion-list-disc notion-block-dbb4c2574a05435a83c0c013077def0f"><li>Plan：要执行哪些计划？AutoGPT 会列出一些步骤。</li></ul><ul class="notion-list notion-list-disc notion-block-fbe932c79fa7483c8da4e4c36b698c53"><li>Criticism：给出了一些执行工作计划的注意事项。</li></ul><ul class="notion-list notion-list-disc notion-block-d20316a819bb419592df70a679d02600"><li>Next Action：经过一系列的思考，下一步要执行怎样的行动。给出一个“Command”和对应的参数“Arguments”。</li></ul><div class="notion-text notion-block-94e3137365f04f5e984698cbbeb65609">AutoGPT完成了一项从思考→行动→反馈→思考的自主循环。</div><div class="notion-text notion-block-b624527176d24c1abc99c62a16b7c28e">依据笔者个人的理解，AutoGPT最主要的贡献是对AI未来形态进行了建模。正如上文所述，未来的人工智能不仅仅是对话，它不仅有大脑，而且还有手和脚。</div><div class="notion-text notion-block-b3a60e79165a4681ae76598c983112dc">这让我想起最近同样很火爆的斯坦福和谷歌的一项研究，他们制作了一个沙盒环境，其中有25个角色，每个角色都有不同的性格和身份，他们会随着时间的推移自主进行交流和举办派对。更加精妙的是，作为沙盒的旁观者，我们可以对沙盒环境进行交互，沙盒中的人工智能会做出相应的反应。</div><div class="notion-text notion-block-9147af58515c4d0da468f58ffe8f7cdd">例如，我们点燃厨房里的灶台，房子里的AI就会停下手头的工作，去救火。</div><div class="notion-text notion-block-7e5e81068cab40e892f2e098e24c7afe">再例如，研究者将沙盒的时间设置为2月13日，即情人节前一天，25个代理会自己拉帮结派、筹划派对。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-98641b1f9e544a21860ea826a004943c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A27540a91-8540-4dee-9526-be9001ff9e34%3AUntitled.png?table=block&amp;id=98641b1f-9e54-4a21-860e-a826a004943c&amp;t=98641b1f-9e54-4a21-860e-a826a004943c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-row notion-block-b8b54c627d9540c4b6f435503db06376"><div class="notion-column notion-block-293d85093f0a4e17b2fdd71316472f9c" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><div class="notion-text notion-block-41ac09aa5544424fb2c3d5e700236355">我们可以看看斯坦福和谷歌的研究人员对沙盒中AI的建模，Preceive、Plan、Reflect、Act等模块是不是很熟悉？</div></div><div class="notion-spacer"></div><div class="notion-column notion-block-f4676920ac1c4caa91e22f66c291de56" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-05876fe2a8c54cf6a1b8fe702df20d24"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ae35f2a59-8d07-47d2-b480-8b3cc160734a%3AUntitled.png?table=block&amp;id=05876fe2-a8c5-4cf6-a1b8-fe702df20d24&amp;t=05876fe2-a8c5-4cf6-a1b8-fe702df20d24" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-1ba218fbfb1949e9ad0bcb5917e1aeab">类似的研究还有浙江大学和微软联合发出的论文，文中提出了一种HuggingGPT的概念，让LLM进行任务规划、选择最适合处理任务的AI模型、执行任务、最后整合并将结果生成。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-07915c41be834a17afdaccc9b9be6d3d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A496ae23b-905b-4d02-83a2-c815bcb87f26%3AUntitled.png?table=block&amp;id=07915c41-be83-4a17-afda-ccc9b9be6d3d&amp;t=07915c41-be83-4a17-afda-ccc9b9be6d3d" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b2df6cb146fc4fab8ad2603601cfcc40" data-id="b2df6cb146fc4fab8ad2603601cfcc40"><span><div id="b2df6cb146fc4fab8ad2603601cfcc40" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b2df6cb146fc4fab8ad2603601cfcc40" title="GPT3.5和GPT4是如何做到这些的？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">GPT3.5和GPT4是如何做到这些的？</span></span></h3><div class="notion-text notion-block-041698d0e9034165b8262c9e206fb526">研究者称，随着语言模型参数量的增长，它们“涌现”出了一系列原本在小型语言模型中不存在的能力，比如逻辑思考的能力；加强了基于用户提供的情境进行上下文学习的能力，被称为“In-Context Learning”。</div><div class="notion-text notion-block-b523a96da3a54923b5d15f8f7d5610fd">这些也正是在ChatGPT推出后，迅速席卷网络的一些重要原因。GPT可以出乎意料地理解我们想让其执行的任务，我们有时候就会发现，即使我们不去网络上寻找各种提示词的“宝典”，只是随意地对其进行对话和指定任务，它就能理解我们的意图并执行对应的行动。</div><div class="notion-text notion-block-ae67479de32b45a980cec8740368bf63">在以前的语言模型应用范式中，我们可能要针对不同的下游任务对模型进行微调，甚至使用不同的模型。比如写代码有写代码的语言模型、聊天机器人有聊天机器人的语言模型、做数学题可能又要用另一套语言模型。每当我们遇到一个全新的下游任务，如果发现模型执行的结果并不好，就得花费大量的时间、金钱去微调模型。</div><div class="notion-text notion-block-d797b4d9f2c94817b595cf3563f14d86">而如今，有了以GPT3.5和GPT-4为首的超大语言模型，我们可以用它们解决大量的下游任务，只需为其提供一个情境、控制其对输出和输出的处理即可。</div><div class="notion-text notion-block-24d5325b45eb40938e08dff5b585ae0d">说白了，普通人理论上也可以通过一些提示词，使用语言模型完成自己想让它执行的任务。如果觉得效果不好，那就再增加一些提示词，大型语言模型支持用户输出很长的提示词，尽可能具体地描述一些任务。</div><div class="notion-text notion-block-f3379b036f7a44988035ce163ce7a650">在各种平台上，我们都可以看到相关的视频和文章。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ba0246540e2c44269ed48024633dae20"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A513c7ca2-8ea2-42c5-a6d7-2934554b47ed%3AUntitled.png?table=block&amp;id=ba024654-0e2c-4426-9ed4-8024633dae20&amp;t=ba024654-0e2c-4426-9ed4-8024633dae20" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-0f96480b0def400cbee21dd0b859d8d8">通过观察现象来认识本质。作为一个普通人和与自然语言处理无关的外行（本文作者本身就是这样的），我们可以忽略繁琐的微调模型技术，利用所谓的“In-Context Learning”、“Chain of Thought”、“Prompt Tuning”技术，让大型语言模型为我们所用（这个美好愿景几乎已经实现）。这些技术和微调范式都是基于不调整模型本身的，因此只要我们了解它们背后的提示词如何编写，就能达到相应的效果。</div><div class="notion-text notion-block-0365668d31744a69a116de1aed5828a1">总之，随着人工智能的发展，成为一个合格的提示词工程师（Prompt Engineer）已经成为一个必备的技能。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-cf8bbbdd1d574b7080feddfe80afa6d0" data-id="cf8bbbdd1d574b7080feddfe80afa6d0"><span><div id="cf8bbbdd1d574b7080feddfe80afa6d0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cf8bbbdd1d574b7080feddfe80afa6d0" title="AutoGPT的提示词"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">AutoGPT的提示词</span></span></h3><div class="notion-text notion-block-461dd21260f247e7b0b191cc515b7368">正如上文所述，各种技术和范式都可以追溯到提示词。对于如今大型语言模型的应用方面，提示词的编写是重中之重。本文将从AutoGPT的源代码入手，找到突破口，使读者能够理解其中的原理并在本地部署。有能力的读者可以尝试复现。</div><div class="notion-text notion-block-25837a79e6434486b2e5b2e249f473a3">首先，在Prompt.py中找到以下代码：</div><div class="notion-text notion-block-e735d9cc2a5c468dbacf4814196b4ec0">其中最引人注目的代码就是这段了</div><div class="notion-text notion-block-dca6efdacbac440499f0973e63b0d3af">从Prompt文件中可以看到，尝试使用名为&quot;prompt_generator&quot;的工具，将一系列命令传递给它。这些命令似乎是AutoGPT执行部分的函数和参数。我们可以看到谷歌搜索、列出Agent、读写文件、执行Python代码、生成图片等各种命令。这些就是AutoGPT的“手”和“脚”，它们的能力可以通过这一部分进行扩展。</div><div class="notion-text notion-block-735c029cc81c46e9954862505ae3b8ba">接下来我们来看看PromptGenerator是如何编写的：</div><div class="notion-text notion-block-13fc7a15799e46cbadc02bbfd2f2e0d1">看以下代码：</div><div class="notion-text notion-block-af2b4059e69b48af8aefe2d527a2fa8d">在这里，AutoGPT规定了从GPT-4模型返回的语言的格式。这也就是为什么在一开始的图片中，Prompt能够如此清晰地思考、指定计划、执行行动并作为反馈进入下一个循环。</div><div class="notion-text notion-block-4ae13a2793ee476783e9c6ec5f686b6e">到了这里，应该大部分读者已经猜到了：AutoGPT理解了当前所能使用的工具和采取的手段（上网、执行Python等），当我们给它提供一个目标时，已经制定好了让它以特定的格式返回。GPT-4需要根据这个格式返回它的思考、理由、计划、反思，并给出要执行的指令，并填上对应的参数，从而在控制台中运行该指令并填写对应的参数。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-e506dbb9f83949beb30db90b8d68fd33" data-id="e506dbb9f83949beb30db90b8d68fd33"><span><div id="e506dbb9f83949beb30db90b8d68fd33" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e506dbb9f83949beb30db90b8d68fd33" title="AutoGPT的一些技术细节"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">AutoGPT的一些技术细节</span></span></h3><div class="notion-text notion-block-6fe787bd6a0e409484a5b91d9db0b610">在上一小节中，我们已经介绍了AutoGPT的核心部分如何编写，感兴趣的人甚至可以自己扩展一些命令进行二次开发。</div><div class="notion-text notion-block-9e0142ed9afa48d58d2f52848decad78">在这一章节中，笔者尝试列出实现AutoGPT时使用的其他一些技术。以下是一些作者了解的技术的介绍。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-c0817efd5ebd449bab66c14d4cc4f4c1" data-id="c0817efd5ebd449bab66c14d4cc4f4c1"><span><div id="c0817efd5ebd449bab66c14d4cc4f4c1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c0817efd5ebd449bab66c14d4cc4f4c1" title="在与GPT-4进行通信时，都发送了哪些内容？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">在与GPT-4进行通信时，都发送了哪些内容？</span></span></h4><div class="notion-text notion-block-fdea84ce5a1247109fadac2f957e4dae">在main.py中，可以看到如下内容：</div><div class="notion-text notion-block-9745c9bdb08d45f8b6c280a91d27befb">在chat_with_ai函数中，我们发送给AI的内容包括提示词、用户输入、完整的信息历史和记忆等。其中，提示词规定了返回格式和可执行的命令。用户输入和信息历史是常规的将它们发送给大型模型。在这里，我们主要讨论如何使用memory。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-bd190d78999645feaf428fc9965e2954" data-id="bd190d78999645feaf428fc9965e2954"><span><div id="bd190d78999645feaf428fc9965e2954" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bd190d78999645feaf428fc9965e2954" title="memory"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">memory</span></span></h4><div class="notion-row notion-block-a8cb137154224542bab77c7fcaa64e82"><div class="notion-column notion-block-6c4b58ca269342aebb74eebd5f823338" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><div class="notion-text notion-block-7149f5e598f94341927aad3154074133">由于 GPT-3.5 和 GPT-4 对文字的处理并不是无限的，我们不能发送无限长的信息。在网页端进行聊天还是小事。在AutoGPT中，AI执行了很多行动，这些行动产生的 &quot;后果&quot; 都需要记录。例如使用谷歌搜索返回的信息、运行 Python 代码返回的信息以及一些报错等。这些内容全部一股脑发回给GPT模型几乎是不可能的，因此我们采取的方法是将其存储在 &quot;记忆&quot; 中。使用了矢量数据库的技术，将信息以数字的形式存储下来。</div><div class="notion-blank notion-block-82093b6cce604c43a6af29a5880220c3"> </div></div><div class="notion-spacer"></div><div class="notion-column notion-block-953534ddeb674ba08b7d755f1ed55e8f" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-54efe595a2e740e0ad842f2cf8121136"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A6cbc79d1-fdc4-4d86-94b6-9dad51fea7a8%3AUntitled.png?table=block&amp;id=54efe595-a2e7-40e0-ad84-2f2cf8121136&amp;t=54efe595-a2e7-40e0-ad84-2f2cf8121136" alt="本地存储的memory" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">本地存储的memory</figcaption></div></figure></div><div class="notion-spacer"></div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6b63d04be2364d578660a43642af844c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A5bbb3633-f1c2-43e8-b612-4e386821a6ce%3AUntitled.jpeg?table=block&amp;id=6b63d04b-e236-4d57-8660-a43642af844c&amp;t=6b63d04b-e236-4d57-8660-a43642af844c" alt="Vector Database" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">Vector Database</figcaption></div></figure><div class="notion-text notion-block-dffd5f28c5f14dbe8627d38b3fe2f35c">当 GPT 准备执行下一轮命令时，它需要从“记忆库”中检索与当前计划和要执行的操作相关的部分，并将其发送。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c029447d667e4fa7b73983c9b44035f2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A57821f83-8955-4ba0-83d7-038d5bdf2bdf%3AUntitled.jpeg?table=block&amp;id=c029447d-667e-4fa7-b739-83c9b44035f2&amp;t=c029447d-667e-4fa7-b739-83c9b44035f2" alt="检索过程=找到最小角度对应的词向量" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">检索过程=找到最小角度对应的词向量</figcaption></div></figure><div class="notion-row notion-block-d40c99b9b268485084c9b90471126189"><div class="notion-column notion-block-faf4d04ca35c47bcb24ce23e5adde2bb" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><div class="notion-text notion-block-2c7249ef9b0943de93c2eff4f1507f10">从 memory 文件夹中可以看出，除了支持本地存储记忆之外，AutoGPT 还应该支持一些云端矢量数据库，这样可以更节省本机内存，但这些数据库并不便宜。</div><div class="notion-blank notion-block-4b2d6f6f080c4645a60279c9c7c28d5d"> </div></div><div class="notion-spacer"></div><div class="notion-column notion-block-39108c4e309e4855a6fc999db2ffffdc" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-20156c570ac846beb6acdc8b946e6bd3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:320.9875183105469px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A996483be-4c59-4479-b769-fe5e63100c6e%3AUntitled.png?table=block&amp;id=20156c57-0ac8-46be-b6ac-dc8b946e6bd3&amp;t=20156c57-0ac8-46be-b6ac-dc8b946e6bd3" alt="memory模块" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">memory模块</figcaption></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-6c51978800534e65b4cfb1e79e343688">在知乎的一篇文章中，很好地总结了GPT如何使用工具以及如何进行记忆的”召回“：</div><div class="notion-row"><a class="notion-bookmark notion-block-93031aa6ecb5474296bd1b9009bf71e1" href="https://zhuanlan.zhihu.com/p/616860260" target="_blank" rel="noopener noreferrer"><div><div class="notion-bookmark-title">ChatGPT 的 4000 个 token 上下文不够用怎么办？</div><div class="notion-bookmark-description">经过短暂的兴奋之后，你意识到只有 4000 个 token 的上下文似乎不能完成你想完成的工作。 然后又经过 GPT-4 发布后的短暂兴奋，你意识到有 32000 个 token 似乎够了。 但是你真的打算把你的整个代码仓库用 32000 …</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-icon"><img src="https://www.notion.so/image/https%3A%2F%2Fstatic.zhihu.com%2Fheifetz%2Fassets%2Fapple-touch-icon-152.81060cab.png?table=block&amp;id=93031aa6-ecb5-4742-96bd-1b9009bf71e1&amp;t=93031aa6-ecb5-4742-96bd-1b9009bf71e1" alt="ChatGPT 的 4000 个 token 上下文不够用怎么办？" loading="lazy" decoding="async"/></div><div class="notion-bookmark-link-text">https://zhuanlan.zhihu.com/p/616860260</div></div></div></a></div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-7115df553cf84ee181a8188a3aaab5b4" data-id="7115df553cf84ee181a8188a3aaab5b4"><span><div id="7115df553cf84ee181a8188a3aaab5b4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7115df553cf84ee181a8188a3aaab5b4" title="一些问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一些问题</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-c5f8d068202b4a70869db40aadf21ec9" style="list-style-type:decimal"><li>在网页读取过程中，遇到反爬程序侦测</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-f2c673992ac64ea6b020deb830f78479" style="list-style-type:decimal"><li>人类反馈的作用并不大</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-b1433a2d16aa4aec9e68fe4319699139" style="list-style-type:decimal"><li>如果用GPT-4来跑，想要执行一个简单的任务就要花费15-30美元，消耗token量非常大</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-video notion-block-57c1230a1e104d37a914875cfdde6864"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:320px"><video playsinline="" controls="" preload="metadata" src="https://file.notion.com/f/f/2433ee53-bf86-44be-98df-6270e44673a1/92d1a582-c252-44ed-9339-9bd0af37c680/AutoGPT%E6%95%85%E9%9A%9C%E6%BC%94%E7%A4%BA.mp4?table=block&amp;id=57c1230a-1e10-4d37-a914-875cfdde6864&amp;spaceId=2433ee53-bf86-44be-98df-6270e44673a1&amp;expirationTimestamp=1794441600000&amp;signature=MBM14v9qAtSNOkiSbPLXMAE2dEWVkcb65DR3aYwXZG0" title="video"></video></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-721bb6536264401db12f6c3715c2ecd9" data-id="721bb6536264401db12f6c3715c2ecd9"><span><div id="721bb6536264401db12f6c3715c2ecd9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#721bb6536264401db12f6c3715c2ecd9" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h3><div class="notion-text notion-block-802ab9065e584155b959ce636d23a332">总结下来，AutoGPT主要做了以下几件事：</div><ol start="1" class="notion-list notion-list-numbered notion-block-6b445c363d0148a8a80213396a39171a" style="list-style-type:decimal"><li>构建了一套GPT自主思考、指定计划、执行行动的循环模型</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-883a7cc290de49aea9c470604ad532ba" style="list-style-type:decimal"><li>以GPT-3.5/GPT-4为”大脑“，通过Prompt使”GPT“能使用工具作为”手脚“</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-d4d1d5fc3dbd481e85fd905b6289cf00" style="list-style-type:decimal"><li>将海量行动产生的数据作为记忆库，在必要时”召回“并用于解决下一轮的问题</li></ol><div class="notion-text notion-block-22803d3ce4b34fbba5ec6173909f1ce8">可以参考以下图片，帮助理解AutoGPT的原理：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-5cc0387bbd5a4eefa899258239dd807b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ae738e209-621e-4695-b4d0-a26bb5bf9187%3AUntitled.png?table=block&amp;id=5cc0387b-bd5a-4eef-a899-258239dd807b&amp;t=5cc0387b-bd5a-4eef-a899-258239dd807b" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-4db7c5592a0a49358123b8f5ee3c0c55" data-id="4db7c5592a0a49358123b8f5ee3c0c55"><span><div id="4db7c5592a0a49358123b8f5ee3c0c55" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4db7c5592a0a49358123b8f5ee3c0c55" title="2023.4.29更新"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2023.4.29更新</span></span></h3><div class="notion-text notion-block-b0e5b555012b469e9a9e675f8b21e9b0">截至今日，AutoGPT已经发布了0.2.2版本，添加了插件功能，这与笔者之前的预期相同。AutoGPT提供了一种创新的思路，未来还会有更多的功能被添加进去，成为其行动的工具。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-4ef51efa123a42408ed2ce960c5de3b4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa762532a-463b-4505-b134-4b0a1c513973%3AUntitled.png?table=block&amp;id=4ef51efa-123a-4240-8ed2-ce960c5de3b4&amp;t=4ef51efa-123a-4240-8ed2-ce960c5de3b4" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-30fdd11227c149de8046a1bb3a250ca9">当然，更新此文的另一个主要目的是告别。原因主要是AutoGPT当前确实无法成为真正的生产力工具，而更像一个精致有趣的玩具。笔者需要把更多精力放在学习更加切实可用的工程上。况且最大的LLM开源库LangChain中已经有对应的实现，AutoGPT项目本身的学习价值也在慢慢贬值。</div><div class="notion-callout notion-gray_background_co notion-block-e45650d2f8e94a1a981813ddb347d8ff"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="📑">📑</span></div><div class="notion-callout-text">大型语言模型仍在等待一个SD时刻，如果每个人都能够在自己的计算机上部署，以非常低廉的价格用于二次开发，那么就会变得非常方便。此外，开放易操作权重和微调对于执行一些特殊的下游任务也非常重要。</div></div><div class="notion-callout notion-gray_background_co notion-block-bc164c1cd8fd4ceda1a2f2b09a60c9e7"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">Written by Aryue，editted by Notion AI. </div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[当一个月提示词工程师是什么体验？]]></title>
            <link>https://www.aryue.com/article/a10df295-bb27-43ac-a21f-c2b55f297a2a</link>
            <guid>https://www.aryue.com/article/a10df295-bb27-43ac-a21f-c2b55f297a2a</guid>
            <pubDate>Thu, 22 Jun 2023 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-a10df295bb2743aca21fc2b55f297a2a"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><blockquote class="notion-quote notion-block-4e0ec05e312f49bc8a108712a7431676"><div>本文章系原创，如有雷同，纯属巧合。</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-64f840429839484b9c73d098e4c8a4a7" data-id="64f840429839484b9c73d098e4c8a4a7"><span><div id="64f840429839484b9c73d098e4c8a4a7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#64f840429839484b9c73d098e4c8a4a7" title="🤔 ChatGPT为我带来的机遇"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤔 ChatGPT为我带来的机遇</span></span></h2><div class="notion-text notion-block-478b7d80c8c341279bccef53ffc9c4ae">在OpenAI推出ChatGPT后，一直不温不火的GPT3.5模型迎来了大爆发。网页和app上到处都能看见网友们花式使用GPT的文章和视频。作为一个路人，可能大多看个热闹，主动研究用AI提高生产力的机会并不多。但随着这股浪潮的发展，传统的个人生产方式终将被慢慢改变。</div><div class="notion-text notion-block-15b434a4bb4047d9a17aed8bcb779392">同时，有很多人正在密切关注这股潮流，并思考这波AI变革能否成为普通人逆袭的机会。在各种公众号上，都能看到铺天盖地的广告和课程，最典型的就是“知识星球”，号称会分享很多ChatGPT变现的秘籍。但是我不得不在这里泼一盆冷水，普通人要通过一些课程和知识星球学到一些知识确实是可以的，但能获得赚钱机会的几率并不大，反而成了这些利用ChatGPT的流量赚钱的人的韭菜，帮助他们成为了第一波吃到ChatGPT红利的人。试想，开设课程和维护社区其实需要花费大量的时间和精力，如果还有那么多可以生财的机会，何不把这些精力用到上面？把赚钱的机会留给素昧平生的人，不符合常理也更不符合人性的本质（最好我是以小人之心度君子之腹）。</div><div class="notion-text notion-block-2d4b2d36dbc545bcb515cc9f154e4e76">引用知乎用户”<b><a class="notion-link" href="https://www.zhihu.com/people/li-cha-de-10-58" target="_blank" rel="noopener noreferrer">李查德</a></b>“的一张图，希望能抛砖引玉。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b949e14ad1584874a31675baeb20e11f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A4ae71fc8-461f-40fc-85a5-e8992eb4f4f0%3AUntitled.png?table=block&amp;id=b949e14a-d158-4874-a316-75baeb20e11f&amp;t=b949e14a-d158-4874-a316-75baeb20e11f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-6a327f4d4af242c4bdae3fb616aad552">当然，ChatGPT的出现确实是个机会。只不过任何时代的机会，都需要靠自己把握。举个身边的例子，作为游戏设计相关专业的学生和从业者，亲眼见证了在游戏行业寒冬之后，反而出现了大量的游戏教育课程和游戏教育培训班。在如今这个时代，已经错过了加入游戏行业的最佳时期，行业内卷和末位淘汰以至于整个部门被砍掉的事情屡见不鲜，这些东西是培训教育机构绝口不提的。</div><div class="notion-text notion-block-4e018d4c2f1c4a9e91d8c6d520f35efb">如果想要抓住ChatGPT的机会，就必须自己去寻找大量的资料和新闻，甚至阅读大量的论文，为自己补充营养。AI会颠覆所有的软件生态，会彻底改变人类的生产力，这点是毋庸置疑的。</div><div class="notion-text notion-block-59118ec3365642c187b179a56dc4d6d2">在年初时，面临毕设开题，我把题目临时换成了《基于大语言模型的游戏原型制作方法研究》。虽然时间很紧，并且面临许多风险，但我还是坚持这个选题，因为我觉得这是一次机会，不仅可以逼迫自己深入地进入到该领域一些前沿的研究中补充营养，而且还能为之后的就业增加更多的可能性。在答辩现场，不出所料，参与答辩的老师们针锋相对地对该选题进行了激烈的探讨和批判。有老师认为，大语言模型不过是提示词的秘笈宝典，可能上升不到科研高度。也有老师认为，我作为一个普通人做这些东西，可能会被行业的巨轮碾过，做出来的东西在毕业答辩之前的某一天被吊打，导致没法毕业。还有一些老师不懂装懂，提出了一些八竿子打不着的问题，毕竟每个人都不能表现出对如此热门的话题没有自己的学术思考，可以理解。</div><div class="notion-text notion-block-4e16ae935d1f4be3ba2057136173c70a">这些激烈的争论和百家争鸣的态度恰恰说明，这是一个非常新的领域，起码对于一个普通211的研究生队伍是非常新的。也许过了一年两年后，老师们的态度才能得到统一。做很新的东西让我拥有了很大的热情，因为做一些传统保守的热门选题，最终也有风险延毕。</div><div class="notion-text notion-block-93408929e1214854b8261148708f45a9">后来反转来了，春招期间，我投了北京某游戏大厂的TD岗位，在面试过程中，他们在了解了我的选题之后，发现和他们的用人需求正好一致，因此所有的面试流程都很顺利。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-0edeeefafb7240f1aad9a337b527da5a" data-id="0edeeefafb7240f1aad9a337b527da5a"><span><div id="0edeeefafb7240f1aad9a337b527da5a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0edeeefafb7240f1aad9a337b527da5a" title="📝在公司做一个月提示工程师的体验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝在公司做一个月提示工程师的体验</span></span></h2><div class="notion-text notion-block-c06f22414a8e473c87e4298987f52cb1">进入公司后，才知道语言模型已经被多个小组开始用于各种行业生产流程中，比如AI编写着色器，以及AI驱动的侦探游戏等。我被分派的方向是使用语言模型编写游戏开发代码，以提高生产效率。</div><div class="notion-text notion-block-0b0f55c80f7f4dcf9d06fedf37f02c2f">每天的工作流程如下：写提示词-提需求-查看代码-运行查看效果-修改提示词，循环往复。在第一周，大大降低了生成错误代码的几率，同时也发现了一个问题。这样的工作其实就是提示词的编写，跟提示工程师以及科研八竿子打不着。</div><div class="notion-text notion-block-dec230f0f2c34d85ad5aff7354ec2b4f">在第二三周，我做了一个方案，主题是如何将提示词的编写提升为提示工程。大体概念就是如何将提示词编写的过程提升为一个模拟现实中的程序员编程的过程，可以自由编辑程序流的各个位置，并以文件的形式读取、写入以及保存，并使用一些工具实现了一个demo。</div><div class="notion-text notion-block-69b86f9fd52f4150b6283578db2e3e60">当天来了很多部门的大佬，本来作为一个实习生可能很少有机会和这些大忙人对上话，不过当天恰巧遇到了这个机会。分享了自己的方案，也获取到了别的小组的产品中使用AI的方案。</div><div class="notion-text notion-block-0efa662c30a44aa6a40da3877502b1db">在之后的工作中，我开始就着这个方案，打造自己的一套AI编写代码的工具流，并涌现出了更多想法。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-5e11143795ed442cb24bdb158fcc72ba" data-id="5e11143795ed442cb24bdb158fcc72ba"><span><div id="5e11143795ed442cb24bdb158fcc72ba" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5e11143795ed442cb24bdb158fcc72ba" title="🤗提示词vs提示工程师vs科研"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗提示词vs提示工程师vs科研</span></span></h2><div class="notion-text notion-block-09c1be170ab24e21baa9a05236eaeb84">在这里提出我自己的一些看法，来区分三者的区别。</div><div class="notion-text notion-block-8f36bea682934287a4bb4446893efde3">提示词的编写，在未来可能更多面向用户端，每一位AI产品的用户都需要掌握这项能力，即如何将自己要做的工作表达出来，并被AI理解。</div><div class="notion-text notion-block-1af80726487f4c3a92275b0050517726">而提示工程的作用在于，让提示词的编写这件事被一个盒子包裹起来，让用户的提示词编写更加简单，用户看到的只是一个入口，出来的是一个结果。在网页端使用过ChatGPT的读者应该都知道，我们大多需要很多轮对话，才能完成一项任务。而提示工程师的工作就是，深谙用户的需求，以及用户都会如何提问，通过工程的形式将AI处理的工程隐藏在黑盒子中，用户只要能看到最终任务完成后的结果即可，从而提高用户使用体验。比如Notion AI，Notion是一款笔记软件，因此大部分时间用户都在和文字打交道，所以Notion AI的提示工程师们需要熟悉文字工作者都有哪些常见的需求。如下图，Notion AI的团队做了一些模板，都是一些常用的功能，比如润色、查看错别字、翻译、总结等。这些功能已经成为我工作中不可或缺的一部分，尤其是最近也在做一个中英双语的课程，使用Notion能够很快地在一个页面中完成所有润色、修改、翻译的工作。</div><div class="notion-text notion-block-fa1c371992894c3ea236581041547b0b">当然，我同时也相信这种交互方式一定是AI还不够智能的一种无奈之举，未来的AI一定会更加明白用户想要什么，而不是靠提示工程师去包装。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-97e16f77b42e4a52ac0dba88cb3c12b7"><div style="position:relative;display:flex;justify-content:center;align-self:start;width:336px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ae64276b4-0aeb-427d-ae5c-195f3ed2d829%3AUntitled.png?table=block&amp;id=97e16f77-b42e-4a52-ac0d-ba88cb3c12b7&amp;t=97e16f77-b42e-4a52-ac0d-ba88cb3c12b7" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-469506d060e7420397fc452ddd2bceb9">以上的案例可能都只能完成一个简单的工作，但如果你看过一些行业最先进的提示工程，比如AI驱动的虚拟小镇、AI游玩我的世界并成功完成了所有任务，就会明白原来最厉害的提示工程师们会这样使用AI。他们不单单是在试图使用AI，还是在探索下一代人工智能的可能性。</div><div class="notion-text notion-block-e2953937d2a243f09f61e04f6a10802e">而提示工程相关的科研应该是什么样的呢？科研界一直倡导，学术科研应该与工程分清界限，但也不能脱离工程，虚无缥缈。离提示工程最近的科研，就是以更好的方法实践提示工程，提供一套方法论，最好是有独创的理论框架和模型。这一点只能作为终极目标，因为如今的工科学术论文并没有太多独创的东西，如果说组合别人的模型和框架，专注于别人研究中的瑕疵一顿猛改也算是科研创新的话，那也姑且能算得上是独创。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-9813b531fbe6495eb2e31ac84f5fd523" data-id="9813b531fbe6495eb2e31ac84f5fd523"><span><div id="9813b531fbe6495eb2e31ac84f5fd523" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9813b531fbe6495eb2e31ac84f5fd523" title="🤗结语"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗结语</span></span></h2><div class="notion-text notion-block-0453b5e98c9a4a909bd361c008ff83f5">如果普通人想抓住这次机遇，首先要明确一点，任何机会都不是唾手可得的，因为你能想到的别人也能想到。最好的方法是不断学习，上手使用这些工具。如果有一定的编程能力，可以尝试提示如何搭建工程，并选择一个垂直领域，深入研究该领域当前的需求，并尝试用提示工程的形式解决。必要时，可以阅读一些论文补充营养，尝试复现一些最前沿的提示工程玩法，这是没有坏处的。</div><div class="notion-blank notion-block-bc06a8ff94c746febfc7f0b41eca14fb"> </div><div class="notion-callout notion-gray_background_co notion-block-efa66371115a4c069550e27e21172245"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">Written by Aryue，editted by Notion AI. </div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2024游戏客户端春招记录]]></title>
            <link>https://www.aryue.com/article/c59726fc-2456-4bdb-8837-d8b59afccfa9</link>
            <guid>https://www.aryue.com/article/c59726fc-2456-4bdb-8837-d8b59afccfa9</guid>
            <pubDate>Fri, 29 Mar 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-c59726fc24564bdb8837d8b59afccfa9"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><blockquote class="notion-quote notion-block-521fb2d080734474a8b6a39a257ad3c6"><div>文章来源说明</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-260e791e2fcc4120bd9f3f48360b952b" data-id="260e791e2fcc4120bd9f3f48360b952b"><span><div id="260e791e2fcc4120bd9f3f48360b952b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#260e791e2fcc4120bd9f3f48360b952b" title="🤔 客户端开发笔试常见知识汇总"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤔 客户端开发笔试常见知识汇总</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-9051ac90392c4b05b13cfccab54a6313" data-id="9051ac90392c4b05b13cfccab54a6313"><span><div id="9051ac90392c4b05b13cfccab54a6313" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9051ac90392c4b05b13cfccab54a6313" title="目录"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">目录</span></span></h3><div class="notion-table-of-contents notion-gray notion-block-b7bce482f6cc4e229dd1f1b1e3905dc8"><a href="#260e791e2fcc4120bd9f3f48360b952b" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">🤔 客户端开发笔试常见知识汇总</span></a><a href="#9051ac90392c4b05b13cfccab54a6313" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">目录</span></a><a href="#1183dc92abb94663a65a5a5d8859523d" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">选择题和简答题高频题目</span></a><a href="#30766ee542cd44079ab68a46f4d1410a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">已知二叉树前序和中序，求后序序列</span></a><a href="#378798e7bc86445babdf82abe1ab3276" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">入栈顺序ABCDEFG，则出栈顺序不可能是___</span></a><a href="#9808ef6a047947088c651dcfe3f362c6" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">排序算法</span></a><a href="#1ee257520477429f8108556d8bb1fc19" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">快速排序</span></a><a href="#035d13b860314ae59f8c4149752c5281" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">冒泡排序</span></a><a href="#d8d17a67b33a4e1d8dc0ebea2232e4f5" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">选择排序</span></a><a href="#04140657565d486a8d9f639557ad4a57" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">插入排序</span></a><a href="#39bad9adffbe40228ba2f792c6d8db9b" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">归并排序</span></a><a href="#dbde8f9de4b048449d43e8d8917af9ec" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">堆排序</span></a><a href="#d0b73df96943474396f8ad8a1fe71bf5" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">希尔排序</span></a><a href="#6e47ebd1a04741bda179665f5875474f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">最后三种</span></a><a href="#777d161eb8154919bb3f37da4c3d462c" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">结构体所占内存</span></a><a href="#677a35aa494d4879a3928d6de830a75e" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">📝算法题</span></a><a href="#d4c85390aa104dfbb6a87587f34f8e8b" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">C++算法题中常用的api整理（转载知乎用户“好吃的无锡油面筋”）</span></a><a href="#51cde095ee8a49ee914821a947475ddb" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">🤗自己积累可能会用上的知识</span></a><a href="#4681984e350a404ab6231ba6bbb99c4e" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">四叉树和八叉树</span></a><a href="#d15e29872f16461f84587be11145d266" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">定义</span></a><a href="#49701e8fa5744f8cb34ecbebd8c7f136" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">应用场景</span></a><a href="#56afd6def60247ba8c3b6708c2035270" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">算法过程</span></a><a href="#7036ed7c8c4843eda40135f8de06affe" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">思考</span></a><a href="#6f4a53595c08483cbfee60aeaa34cccc" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">图形学相关</span></a><a href="#834b83bb37d84d949fa7b3dc60ef0941" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">渲染管线</span></a><a href="#ac353b6fa4144dfebd3307ab59e0b7ad" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">参考文章</span></a></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1183dc92abb94663a65a5a5d8859523d" data-id="1183dc92abb94663a65a5a5d8859523d"><span><div id="1183dc92abb94663a65a5a5d8859523d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1183dc92abb94663a65a5a5d8859523d" title="选择题和简答题高频题目"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>选择题和简答题高频题目</b></span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-30766ee542cd44079ab68a46f4d1410a" data-id="30766ee542cd44079ab68a46f4d1410a"><span><div id="30766ee542cd44079ab68a46f4d1410a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#30766ee542cd44079ab68a46f4d1410a" title="已知二叉树前序和中序，求后序序列"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">已知二叉树前序和中序，求后序序列</span></span></h3><div class="notion-text notion-block-d6460b40fafb435495b79f6cf97ff855">首先知道二叉树的三种序列分别代表什么含义：</div><ol start="1" class="notion-list notion-list-numbered notion-block-3da5c34c572644a99997b98a1dd14093" style="list-style-type:decimal"><li>前序：根左右</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-6498be052d5042898a7cf5304a05739d" style="list-style-type:decimal"><li>中序：左根右</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-b8abf5854f18449a82e023e5f5fb5a2a" style="list-style-type:decimal"><li>后序：左右根</li></ol><div class="notion-text notion-block-bd08961f838146e991cc2f8e0a951a24">因此，如果已知前序，那个第一个节点一定是根节点，然后根据中序序列，就能切出左子树和右子树，一步步递归得到整个序列。这种题目只要花费一定时间，都能推出来，并且最后可以反过来验算，了解方法即可达到100%正确率！</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-378798e7bc86445babdf82abe1ab3276" data-id="378798e7bc86445babdf82abe1ab3276"><span><div id="378798e7bc86445babdf82abe1ab3276" class="notion-header-anchor"></div><a class="notion-hash-link" href="#378798e7bc86445babdf82abe1ab3276" title="入栈顺序ABCDEFG，则出栈顺序不可能是___"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">入栈顺序ABCDEFG，则出栈顺序不可能是___</span></span></h3><div class="notion-text notion-block-1bf9d96ea56142f780ff496f8e07c5e8">这种序列就看哪一个元素是第一个不按顺序出栈的。</div><div class="notion-text notion-block-95e5776679154e4ca0cfed9a4092ec01">比如ABCDEFG，看似出栈和入栈顺序一样，但是是合理的，因为进去之后马上出栈就可以！</div><div class="notion-text notion-block-fa230a51a9934eae8b4b73b0549e8ce2">但如果是ADxxxxx，那么你就知道了，B在栈底，C在B上面，此时便会出现出栈序列的矛盾。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-9808ef6a047947088c651dcfe3f362c6" data-id="9808ef6a047947088c651dcfe3f362c6"><span><div id="9808ef6a047947088c651dcfe3f362c6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9808ef6a047947088c651dcfe3f362c6" title="排序算法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">排序算法</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ee257520477429f8108556d8bb1fc19" data-id="1ee257520477429f8108556d8bb1fc19"><span><div id="1ee257520477429f8108556d8bb1fc19" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee257520477429f8108556d8bb1fc19" title="快速排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>快速排序</b></span></span></h4><div class="notion-text notion-block-1f67beb1ad3d448f9b1577c5656e2c0c">最高频的考点，可以从以下多个方面考察：</div><ol start="1" class="notion-list notion-list-numbered notion-block-a14731fe73094266a46e7c8470bd92d7" style="list-style-type:decimal"><li>基础概念</li></ol><div class="notion-text notion-block-4c8e42512c4c4acb9858b1d8b2f02b30">时间复杂度？是否稳定？</div><ol start="2" class="notion-list notion-list-numbered notion-block-49fb812baae5417ba4bef6b0c29ab4d1" style="list-style-type:decimal"><li>具体流程</li></ol><div class="notion-text notion-block-13698c9805e349daa39b1ff6c61e3710">如果选择最后一个元素作为基准元素，那么排序完成一共需要几次比较？</div><ol start="3" class="notion-list notion-list-numbered notion-block-eb641428f63742a196225f4e57ed0655" style="list-style-type:decimal"><li>手撸实现</li></ol><div class="notion-text notion-block-e7c8a3e2d6f241d3863385663af2e9c5">理论上只要知道第三条，1、2条的考点也不会被难倒。快排的算法实现就两条，递归和左右指针。一般都是以第一个元素或者最后一个元素为基准，相当于挖了个坑，然后从另一侧找到第一个比基准元素大（或者小）的元素，交换；那么另一侧原来的位置就又多出来个坑，从反面找到第一个比基准元素小（或者大）的元素，交换，重复这个过程知道left==right。此时就能达到左侧都比基准元素大，右侧均比基准元素小的状态了，最后迭代排列两个左右区间。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-035d13b860314ae59f8c4149752c5281" data-id="035d13b860314ae59f8c4149752c5281"><span><div id="035d13b860314ae59f8c4149752c5281" class="notion-header-anchor"></div><a class="notion-hash-link" href="#035d13b860314ae59f8c4149752c5281" title="冒泡排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>冒泡排序</b></span></span></h4><div class="notion-text notion-block-690d13ba7993486c94d5673864099142">从后往前遍历的话，每一轮都能把最大（或者最小）的元素不断交换到最前面。</div><div class="notion-text notion-block-8768c1e1a21749dabc9da8aa34ea348d">实现思路非常简单，并且算法稳定。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-d8d17a67b33a4e1d8dc0ebea2232e4f5" data-id="d8d17a67b33a4e1d8dc0ebea2232e4f5"><span><div id="d8d17a67b33a4e1d8dc0ebea2232e4f5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d8d17a67b33a4e1d8dc0ebea2232e4f5" title="选择排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>选择排序</b></span></span></h4><div class="notion-text notion-block-85ba998be8704f578e8bb5f453f0bbc1">每一轮找到一个最值，放在序列最前面。</div><div class="notion-text notion-block-42c8dffab96b427eb32b4ecf858ef139">是不稳定。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-04140657565d486a8d9f639557ad4a57" data-id="04140657565d486a8d9f639557ad4a57"><span><div id="04140657565d486a8d9f639557ad4a57" class="notion-header-anchor"></div><a class="notion-hash-link" href="#04140657565d486a8d9f639557ad4a57" title="插入排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>插入排序</b></span></span></h4><div class="notion-text notion-block-879a53f878654cc4bc1bcb800a14a001">数组分为两段，一段为已经排序的，另一段为未排序的。</div><div class="notion-text notion-block-29f163d73c684f8ca55dc19fff123b06">每次选择未排序序列中的第一个，找到其在有序序列中的位置。</div><div class="notion-text notion-block-b7201f4588104d758ab4452c60232e40">是一种稳定算法</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-39bad9adffbe40228ba2f792c6d8db9b" data-id="39bad9adffbe40228ba2f792c6d8db9b"><span><div id="39bad9adffbe40228ba2f792c6d8db9b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#39bad9adffbe40228ba2f792c6d8db9b" title="归并排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>归并排序</b></span></span></h4><div class="notion-text notion-block-fcee421f9afe4466b950710c9d5f869d">不断二分数组，分到不能在分之后，反向递归，合并成有序序列。</div><div class="notion-text notion-block-154fdf083f124a23bbce20a0aad6dd72">比如（54321）需要排成从小到大。</div><div class="notion-text notion-block-716d86263b9f459b80229a896fa345c1">第一次分成543，21</div><div class="notion-text notion-block-aa1b190b0c8c4b03ae080fa6a5c94fdd">第二次分成54 3 21</div><div class="notion-text notion-block-74fb3ff864974417a2e779649c705f9e">第三次分成5 4 3 2 1</div><div class="notion-text notion-block-8461ad50eadb4c599389b50dbbb38ccf">第一次归并为45 3 12</div><div class="notion-text notion-block-da36a6cbb5c2402196d34763bb747500">第二次归并为345 12</div><div class="notion-text notion-block-6dbfbd12b5544154b3b9d53dc7f3a4a7">第三次归并为12345</div><div class="notion-text notion-block-de0250ce544d4d948d964e8ef7877789">简单的问题，可以问归并算法是否稳定（稳定），时间复杂度。</div><div class="notion-text notion-block-ff6805dd4810411b9f02420a762e5960">复杂一点，需要手写代码，但总体来说不难。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-dbde8f9de4b048449d43e8d8917af9ec" data-id="dbde8f9de4b048449d43e8d8917af9ec"><span><div id="dbde8f9de4b048449d43e8d8917af9ec" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dbde8f9de4b048449d43e8d8917af9ec" title="堆排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>堆排序</b></span></span></h4><div class="notion-text notion-block-e1641088c3354e4c8bfb9f13e1cdab0b">堆可以用数组实现，因为可以将数组视为一个完全二叉树，那么根节点和子节点在数组中的索引是有规律的，比如根节点数组下标为i，左叶子就是2i，右叶子是2i+1。（如果有的话）</div><div class="notion-text notion-block-8b6c4a552b76417f9abd43404f772e3b">堆排序的流程如下：</div><ol start="1" class="notion-list notion-list-numbered notion-block-725b0f5b3d944e52b4750dd6d802920c" style="list-style-type:decimal"><li>建堆，从最后一个非叶子节点开始，与其孩子交换，将较大（小）的元素往上调整</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-af4b1787de20456288b78d41c68dc065" style="list-style-type:decimal"><li>此时堆顶元素就是最大值，将其与最后一个元素交换，将剩下的堆元素重新调整为堆</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-0a857b0b3f404cb3986026f5a8d357ee" style="list-style-type:decimal"><li>反复这个过程，知道堆中只剩下一个元素</li></ol><div class="notion-text notion-block-01920f47e9a44ee6b483ca81b4862be9">这是一种不稳定的算法，且时间复杂度为nlogn级别。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-d0b73df96943474396f8ad8a1fe71bf5" data-id="d0b73df96943474396f8ad8a1fe71bf5"><span><div id="d0b73df96943474396f8ad8a1fe71bf5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d0b73df96943474396f8ad8a1fe71bf5" title="希尔排序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>希尔排序</b></span></span></h4><div class="notion-text notion-block-ecdc6200509744efb78379976c43a5fb">没有研究过具体实现，只知道平均复杂度为n的1.3次幂，最坏为n平方，最好为n。</div><div class="notion-text notion-block-a1b06f38f15444b9a902066e7635c44f">是一种不稳定的排序算法。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-6e47ebd1a04741bda179665f5875474f" data-id="6e47ebd1a04741bda179665f5875474f"><span><div id="6e47ebd1a04741bda179665f5875474f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6e47ebd1a04741bda179665f5875474f" title="最后三种"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>最后三种</b></span></span></h4><div class="notion-text notion-block-cbabe1dc14444f05a989b07e6dccf44d">计数排序、桶排序和箱排序，属于低频考点</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-777d161eb8154919bb3f37da4c3d462c" data-id="777d161eb8154919bb3f37da4c3d462c"><span><div id="777d161eb8154919bb3f37da4c3d462c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#777d161eb8154919bb3f37da4c3d462c" title="结构体所占内存"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结构体所占内存</span></span></h3><div class="notion-row"><a class="notion-bookmark notion-block-4db96774328f4b92894cf2944a3513d4" href="https://blog.csdn.net/houxian1103/article/details/133546190" target="_blank" rel="noopener noreferrer"><div><div class="notion-bookmark-title">C++ 内存空间总结_c++结构体占用内存-CSDN博客</div><div class="notion-bookmark-description">文章浏览阅读600次。因为结构体有时候需要字节对齐。一般而言，struct 的 sizeof 是所有成员字节对齐后长度相加，而 union 的 sizeof 是取最大的成员长度。在默认情况下，编译器为每一个变量或数据单元按其自然对界条件分配空间。一般地，可以通过下面的方法来改变默认的对界条件：(1) 使用伪指令#pragma pack(n)，C编译器将按照n个字节对齐。(2) 使用伪指令#pragma pack()，取消自定义字节对齐方式。_c++结构体占用内存</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-icon"><img src="https://www.notion.so/image/https%3A%2F%2Fg.csdnimg.cn%2Fstatic%2Flogo%2Ffavicon32.ico?table=block&amp;id=4db96774-328f-4b92-894c-f2944a3513d4&amp;t=4db96774-328f-4b92-894c-f2944a3513d4" alt="C++ 内存空间总结_c++结构体占用内存-CSDN博客" loading="lazy" decoding="async"/></div><div class="notion-bookmark-link-text">https://blog.csdn.net/houxian1103/article/details/133546190</div></div></div></a></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-677a35aa494d4879a3928d6de830a75e" data-id="677a35aa494d4879a3928d6de830a75e"><span><div id="677a35aa494d4879a3928d6de830a75e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#677a35aa494d4879a3928d6de830a75e" title="📝算法题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝算法题</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-d4c85390aa104dfbb6a87587f34f8e8b" data-id="d4c85390aa104dfbb6a87587f34f8e8b"><span><div id="d4c85390aa104dfbb6a87587f34f8e8b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d4c85390aa104dfbb6a87587f34f8e8b" title="C++算法题中常用的api整理（转载知乎用户“好吃的无锡油面筋”）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">C++算法题中常用的api整理（转载知乎用户“好吃的无锡油面筋”）</span></span></h3><div class="notion-text notion-block-a28ab742f48c48a0ac1dfba7a9d54f06"><b>std::vector&lt;T&gt;</b></div><ul class="notion-list notion-list-disc notion-block-1fcbf7168a214a2fa1adb201a0ff7995"><li>push_back(const T&amp; value): 添加元素至末尾</li></ul><ul class="notion-list notion-list-disc notion-block-212e79e29fc844858d6a1f8293296f27"><li>pop_back(): 移除末尾元素</li></ul><ul class="notion-list notion-list-disc notion-block-e8c37a88be364598b81f8d5b3a0e8a25"><li>size(): 获取元素数量</li></ul><ul class="notion-list notion-list-disc notion-block-51f6e9d42765426087eb8d8733aa4e7c"><li>empty(): 检查容器是否为空</li></ul><ul class="notion-list notion-list-disc notion-block-1805c0e9a90641bbbf75b3669ec288ce"><li>clear(): 清空容器</li></ul><ul class="notion-list notion-list-disc notion-block-ed4541f225c94e9d8c54fb9c79d82eb9"><li>begin(), end(): 获取迭代器</li></ul><div class="notion-text notion-block-3c8d28999da5467da931dfc1625190a3"><b>std::list&lt;T&gt;</b></div><ul class="notion-list notion-list-disc notion-block-13728db43283401f8020fec161e1a8fc"><li>push_back(const T&amp; value), push_front(const T&amp; value): 添加元素</li></ul><ul class="notion-list notion-list-disc notion-block-878bbe99f9de460fa8e2713c2674f110"><li>pop_back(), pop_front(): 移除元素</li></ul><ul class="notion-list notion-list-disc notion-block-edf19d305e1940bf90436d7040171fda"><li>size(), empty(), clear(): 同std::vector</li></ul><ul class="notion-list notion-list-disc notion-block-dcc0d32da8d3480b811e16c28dc1675b"><li>begin(), end(): 获取迭代器</li></ul><div class="notion-text notion-block-30aba370a685412fb8615c7961698f66"><b>std::set&lt;T&gt;</b></div><ul class="notion-list notion-list-disc notion-block-ea985955cf6645938260caecf814b4ae"><li>insert(const T&amp; value): 插入元素</li></ul><ul class="notion-list notion-list-disc notion-block-2622d5a8fdd341808a93fe26e23d6c68"><li>erase(const T&amp; value): 删除元素</li></ul><ul class="notion-list notion-list-disc notion-block-a392694944d549eab45fe461fa474c65"><li>find(const T&amp; value): 查找元素</li></ul><ul class="notion-list notion-list-disc notion-block-88525112842443ccb42597c60712f627"><li>size(), empty(), clear(), begin(), end(): 同std::vector</li></ul><div class="notion-text notion-block-1c1f81126e9b41f5a0e6e02beeacb5f8"><b>std::map&lt;K, V&gt;, std::unordered_map&lt;K, V&gt;</b></div><ul class="notion-list notion-list-disc notion-block-5b79f7472edb45d981d8473032e4c717"><li>insert(std::make_pair(key, value)): 插入键值对</li></ul><ul class="notion-list notion-list-disc notion-block-195db1be62634fb7bffe4dc0fbd1d5f2"><li>erase(const K&amp; key): 根据键删除元素</li></ul><ul class="notion-list notion-list-disc notion-block-7683dd4f97d140c3a5adac8daefd3e45"><li>find(const K&amp; key): 查找键</li></ul><ul class="notion-list notion-list-disc notion-block-d027076276b74f64a3f9ee48ad0e4f13"><li>size(), empty(), clear(), begin(), end(): 同std::vector</li></ul><div class="notion-text notion-block-f529bf83f22f4ff1b2fb8b1f14d3673e"><b>std::queue&lt;T&gt;</b></div><ul class="notion-list notion-list-disc notion-block-2787891c3c95467c875c92d4a6d07ebc"><li>push(const T&amp; value): 添加元素至末尾</li></ul><ul class="notion-list notion-list-disc notion-block-e01627a5c29b4074b4943bbf3a810d34"><li>pop(): 移除首元素</li></ul><ul class="notion-list notion-list-disc notion-block-59d2c421cf1c454896d64e28322101ef"><li>front(): 获取首元素</li></ul><ul class="notion-list notion-list-disc notion-block-0ba8ca68c1b2465f92b5fafb2e5ca293"><li>size(), empty(): 同std::vector</li></ul><div class="notion-text notion-block-6e33341adffa442cb54a7dfc56cdb09a"><b>std::stack&lt;T&gt;</b></div><ul class="notion-list notion-list-disc notion-block-354c61a1a97c40869ce80feb4b952b45"><li>push(const T&amp; value): 添加元素至顶部</li></ul><ul class="notion-list notion-list-disc notion-block-413a35ceec8040fba2a25bc9064771bc"><li>pop(): 移除顶部元素</li></ul><ul class="notion-list notion-list-disc notion-block-8ac3d03462ce4ec69c9ded7000748b10"><li>top(): 获取顶部元素</li></ul><ul class="notion-list notion-list-disc notion-block-379e5fa7b82045cbad8533876e8b43f0"><li>size(), empty(): 同std::vector</li></ul><div class="notion-text notion-block-ff5ba9a65c2645e78583ca20f73359d5"><b>std::priority_queue&lt;T&gt;</b></div><ul class="notion-list notion-list-disc notion-block-6bf8f8d25a4d4bfa83d7470511141755"><li>push(const T&amp; value): 插入元素</li></ul><ul class="notion-list notion-list-disc notion-block-c39f26d36a524bce80cf872121787dc4"><li>pop(): 移除顶部元素</li></ul><ul class="notion-list notion-list-disc notion-block-b90a2096f80c484d849e63fda69b397a"><li>top(): 获取顶部元素</li></ul><ul class="notion-list notion-list-disc notion-block-8f7a91da091c4b569961d7fb15ddcce5"><li>size(), empty(): 同std::vector</li></ul><div class="notion-text notion-block-6f1d5ecb73a745979122afcc04ee243f"><b>♥️字符串相关：</b></div><div class="notion-text notion-block-31831c0a95064c08a588292c7ad45305"><b>getline</b></div><div class="notion-text notion-block-4a6547a5efa34f84bb8c7bbb99eef96a">std<b>::</b>string line;
std<b>::</b>getline( cin, line ); <em>// 从标准输入读取一整行</em></div><div class="notion-text notion-block-db3462faf5534ed4a16f18a1097bee10"><b>stringstream</b></div><ul class="notion-list notion-list-disc notion-block-3221e3eb7eff4786a4af0a809a4dd385"><li>str(): 获取或设置流中的字符串内容</li></ul><ul class="notion-list notion-list-disc notion-block-a707b4d07e8f49a78078c7b11f624066"><li>get(): 获取下一个字符</li></ul><ul class="notion-list notion-list-disc notion-block-05571afca0094381bf75413f1d2d6023"><li>&lt;&lt;: 插入操作符，将数据插入到流中</li></ul><ul class="notion-list notion-list-disc notion-block-c983c747eea441bbbfd60913df0b8e75"><li>&gt;&gt;: 提取操作符，从流中提取数据</li></ul><ul class="notion-list notion-list-disc notion-block-80b3c6cc1b6a4638a4073ba3b909668f"><li>clear(): 清除流的状态标志</li></ul><ul class="notion-list notion-list-disc notion-block-21ad783973334e96b37aa122add8f041"><li>peek(): 查看下一个字符</li></ul><div class="notion-text notion-block-a413ef2f9fce4cd2a30ecc110ef2b080">&quot;1,234,567&quot;去掉逗号，可以通过以下方法来实现：</div><div class="notion-text notion-block-bac5a47dc3374bd29a7168a97d02ed81">字符串相关处理我一般可能会接收之后遍历一次字符串，去掉‘，’，这里的做法明显是一种更好的做法。</div><div class="notion-text notion-block-1ebc4948988542cda215b8ca2a51211c"><b>其它</b></div><div class="notion-text notion-block-9e210bc671494c6fac8bd0d6c1b85b91"><b>构建数组 </b></div><div class="notion-text notion-block-bc096fd6549249289f604044b2b41bb3">int arr[][]={0,1,0,-1,1,0,-1,0};</div><div class="notion-text notion-block-bc145729a00c42fe9b3f638b704f1a17"><b>sort函数</b></div><div class="notion-text notion-block-aaad0f8e0c1a4d5d9fb66b40d1c36a79">可以定义一个返回值为bool的cmp函数作为比较器，在一些题目中很有用</div><div class="notion-text notion-block-d7394229d9a04ff69652faa69e1f500d"><b>stoi和stof函数</b></div><div class="notion-text notion-block-72703b3ab51f4c698c151b83bca301ee">将字符串转为特定类型值</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-51cde095ee8a49ee914821a947475ddb" data-id="51cde095ee8a49ee914821a947475ddb"><span><div id="51cde095ee8a49ee914821a947475ddb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#51cde095ee8a49ee914821a947475ddb" title="🤗自己积累可能会用上的知识"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗自己积累可能会用上的知识</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-4681984e350a404ab6231ba6bbb99c4e" data-id="4681984e350a404ab6231ba6bbb99c4e"><span><div id="4681984e350a404ab6231ba6bbb99c4e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4681984e350a404ab6231ba6bbb99c4e" title="四叉树和八叉树"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四叉树和八叉树</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-d15e29872f16461f84587be11145d266" data-id="d15e29872f16461f84587be11145d266"><span><div id="d15e29872f16461f84587be11145d266" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d15e29872f16461f84587be11145d266" title="定义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">定义</span></span></h4><div class="notion-text notion-block-05acc258d8c34108bc43b7e97e6082a3">一种树型数据结构，分别代表最多有几个子节点。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-49701e8fa5744f8cb34ecbebd8c7f136" data-id="49701e8fa5744f8cb34ecbebd8c7f136"><span><div id="49701e8fa5744f8cb34ecbebd8c7f136" class="notion-header-anchor"></div><a class="notion-hash-link" href="#49701e8fa5744f8cb34ecbebd8c7f136" title="应用场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">应用场景</span></span></h4><div class="notion-text notion-block-8b5c92851c61478b82d5fbd9768baec2">对空间进行分割，方便检测互相之间的碰撞，或者其它需要两两检测的场景。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-56afd6def60247ba8c3b6708c2035270" data-id="56afd6def60247ba8c3b6708c2035270"><span><div id="56afd6def60247ba8c3b6708c2035270" class="notion-header-anchor"></div><a class="notion-hash-link" href="#56afd6def60247ba8c3b6708c2035270" title="算法过程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">算法过程</span></span></h4><div class="notion-text notion-block-98fb6c70251c4945b808748794746c49">以四叉树为例，其理解逻辑参考堆：</div><ol start="1" class="notion-list notion-list-numbered notion-block-f309df033f754174ba2fbab58eb889eb" style="list-style-type:decimal"><li>第一步是如何构建四叉树，四叉树一般会有一个maxDepth和一个capcity，前者即最深遍历深度，用于控制整体规模，后者用于限制每个树节点存储的孩子个数。在构建时，当超过capcity时，开始对当前空间进行四等分，查询当前节点在哪个区间并添加。如果当前节点处在交叉位置，则需要添加到父节点处，无视capcity的存在</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-f8eae9d911e246c087dc6e98f7f7aa2c" style="list-style-type:decimal"><li>第二步是应用，显然，当四叉树已经构建好后，假设当前需要求一个圆A的所有碰撞时，可以快速过滤无用的节点。其父节点以及所有兄弟节点即为它所能接触到的所有可能的节点！</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-64b05a79cbda4f198e8f249cfbe14fc8" style="list-style-type:decimal"><li>另外就是插入和删除，插入跟构建时的步骤一样；删除时需要注意，可能会动态调整树的结构，达到优化目的。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-7036ed7c8c4843eda40135f8de06affe" data-id="7036ed7c8c4843eda40135f8de06affe"><span><div id="7036ed7c8c4843eda40135f8de06affe" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7036ed7c8c4843eda40135f8de06affe" title="思考"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">思考</span></span></h4><div class="notion-text notion-block-0cc486bbd79e41e898eed4ebad58bab9">学习一个知识，如果没有深刻实践的话，很难能有深刻理解或者记忆。但复习时也要抓住根本目的，如果是为了找工作，未必面面俱到，对每个领域都有所了解就很好了。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-6f4a53595c08483cbfee60aeaa34cccc" data-id="6f4a53595c08483cbfee60aeaa34cccc"><span><div id="6f4a53595c08483cbfee60aeaa34cccc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6f4a53595c08483cbfee60aeaa34cccc" title="图形学相关"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">图形学相关</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-834b83bb37d84d949fa7b3dc60ef0941" data-id="834b83bb37d84d949fa7b3dc60ef0941"><span><div id="834b83bb37d84d949fa7b3dc60ef0941" class="notion-header-anchor"></div><a class="notion-hash-link" href="#834b83bb37d84d949fa7b3dc60ef0941" title="渲染管线"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">渲染管线</span></span></h4><div class="notion-text notion-block-f7bedaa0e0fa4a019d2af89d7dd2b691">应用阶段—几何阶段—光栅化阶段</div><div class="notion-text notion-block-7c6871999bba46ef9281e0bf40c326cd">顶点着色器出现在几何几段，片元着色器出现在光栅化阶段</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-ac353b6fa4144dfebd3307ab59e0b7ad" data-id="ac353b6fa4144dfebd3307ab59e0b7ad"><span><div id="ac353b6fa4144dfebd3307ab59e0b7ad" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ac353b6fa4144dfebd3307ab59e0b7ad" title="参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考文章</span></span></h2><div class="notion-row"><a class="notion-bookmark notion-block-620093892f5d4949a158120b7a03729f" href="https://zhuanlan.zhihu.com/p/646082578" target="_blank" rel="noopener noreferrer"><div><div class="notion-bookmark-title">好吃的无锡油面筋——STL与数据结构篇（在写）</div><div class="notion-bookmark-description">前言写完再改标题。其他面筋： 周杰伦：好吃的无锡油面筋——C++（在写）周杰伦：好吃的无锡油面筋——机组计网OS篇（在写） STL各种容器的查找、删除和插入的时间复杂度（性能比较）♥️容器知道哪些讲一讲 ♥️…</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-icon"><img src="https://www.notion.so/image/https%3A%2F%2Fstatic.zhihu.com%2Fheifetz%2Fassets%2Fapple-touch-icon-152.81060cab.png?table=block&amp;id=62009389-2f5d-4949-a158-120b7a03729f&amp;t=62009389-2f5d-4949-a158-120b7a03729f" alt="好吃的无锡油面筋——STL与数据结构篇（在写）" loading="lazy" decoding="async"/></div><div class="notion-bookmark-link-text">https://zhuanlan.zhihu.com/p/646082578</div></div></div><div class="notion-bookmark-image"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fpic1.zhimg.com%2Fv2-da4e60c4b9e23a2322ae9b64c4439f80_720w.jpg%3Fsource%3D172ae18b?table=block&amp;id=62009389-2f5d-4949-a158-120b7a03729f&amp;t=62009389-2f5d-4949-a158-120b7a03729f" alt="好吃的无锡油面筋——STL与数据结构篇（在写）" loading="lazy" decoding="async"/></div></a></div><div class="notion-text notion-block-ffb5537777984cc980599bd9aca2f238">致谢：</div><div class="notion-callout notion-gray_background_co notion-block-67830f89b1434075af4faac8a023e6f4"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">Written by Aryue,editted by Notion AI.</div></div><div class="notion-blank notion-block-8b7877f50f1f4efdb872c12da20dcd33"> </div><div class="notion-blank notion-block-c39d239948234d70b48d923b289a10fe"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[代码随想录-单调栈、图论、并查集]]></title>
            <link>https://www.aryue.com/article/396d3c99-b597-4eff-ab9d-3e7853341241</link>
            <guid>https://www.aryue.com/article/396d3c99-b597-4eff-ab9d-3e7853341241</guid>
            <pubDate>Sat, 06 Apr 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[代码随想录 单调栈、图论、并查集总结]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-396d3c99b5974effab9d3e7853341241"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><blockquote class="notion-quote notion-block-5d7055a3f84d4835819b1f72d3b614fc"><div>文章来源说明</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-90d0aa68e2f44f8ba1d6163c83dda503" data-id="90d0aa68e2f44f8ba1d6163c83dda503"><span><div id="90d0aa68e2f44f8ba1d6163c83dda503" class="notion-header-anchor"></div><a class="notion-hash-link" href="#90d0aa68e2f44f8ba1d6163c83dda503" title="🤔 模块说明"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤔 模块说明</span></span></h2><div class="notion-text notion-block-a064eca768f44509bc8d2e9de5acff4e">一刷时，到动态规划部分已经结束了。本模块为二刷时，代码随想录新更新的两大模块，随着互联网行业的进一步内卷，图论的题目在笔试中也的确开始频繁出现。</div><div class="notion-text notion-block-65172cb2ee9b4339a7e25c5678c9a238">那么接下来，就按照单调栈、图论和并查集的顺序归纳总结。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1ab947022dea47d687e38f8c717c7a7d" data-id="1ab947022dea47d687e38f8c717c7a7d"><span><div id="1ab947022dea47d687e38f8c717c7a7d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ab947022dea47d687e38f8c717c7a7d" title="📝单调栈"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝单调栈</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-6b57be40b8c94ce0ab0c68f969905d85" data-id="6b57be40b8c94ce0ab0c68f969905d85"><span><div id="6b57be40b8c94ce0ab0c68f969905d85" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6b57be40b8c94ce0ab0c68f969905d85" title="单调栈的应用场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">单调栈的应用场景</span></span></h3><div class="notion-text notion-block-a6e11faa467740fa9bbd17dd2bece9a2">首先看单调栈的模板题：</div><div class="notion-text notion-block-c5bd2e215ba743f7808136311fcf9288">按照惯例，解决一个算法问题，首先考虑它的暴力解法。这道题的暴力解法当然是遍历数组中每一个元素之后的所有元素，并记录下来，其时间复杂度为O($n^2$)。</div><div class="notion-text notion-block-e0f985e84acf422394525fbd7f698fb5">单调栈的存在是为了通过一个栈的辅助，用空间换取时间，将时间复杂度降低到O(n)级别。具体操作如下：</div><ol start="1" class="notion-list notion-list-numbered notion-block-0da918d811f340ed89c8b34d95fdd9b3" style="list-style-type:decimal"><li>从数组的第一个元素开始遍历，将其压入栈中。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-184c17cd4fdf4ce4a0ff1bd77d3ec3c7" style="list-style-type:decimal"><li>如果当前元素小于等于栈顶元素，将当前元素压入栈中。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-bd7785d3fc454995b61905b80fce2499" style="list-style-type:decimal"><li>如果当前元素大于栈顶元素，弹出栈顶元素。这时，就找到了栈顶元素对应的答案。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-060183cc1f314911b5cc4a5e7414ea87" style="list-style-type:decimal"><li>重复第三步，直到所有比当前元素小的栈顶元素全部弹出，然后将当前元素压入栈中。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-bae94f88b66345c68966cdf54c6a2a61" style="list-style-type:decimal"><li>最后，仍留在栈中的元素，其答案都是0，可以在初始化数组时预设。</li></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-c33b5a47f81541b6bb5a72c4d723790d" data-id="c33b5a47f81541b6bb5a72c4d723790d"><span><div id="c33b5a47f81541b6bb5a72c4d723790d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c33b5a47f81541b6bb5a72c4d723790d" title="模板题的变形"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">模板题的变形</span></span></h3><div class="notion-text notion-block-a94b4a84dac040af9e743ddaac36f031">下一个更大元素I     <b><a class="notion-link" href="https://leetcode.cn/problems/next-greater-element-i/" target="_blank" rel="noopener noreferrer">力扣题目链接</a></b></div><div class="notion-text notion-block-67ad0b8c30b44dbf9d08490189394a87">下一个更大元素II    <b><a class="notion-link" href="https://leetcode.cn/problems/next-greater-element-ii/" target="_blank" rel="noopener noreferrer">力扣题目链接</a></b></div><div class="notion-text notion-block-1f61005965b94377a14fbe6c115ee5bf">单调栈更多是一种思想，如果掌握了其实解决这两道题也不是很难。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-36cfa2e2680147e18a2c5d38c7d8f68e" data-id="36cfa2e2680147e18a2c5d38c7d8f68e"><span><div id="36cfa2e2680147e18a2c5d38c7d8f68e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#36cfa2e2680147e18a2c5d38c7d8f68e" title="难题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">难题</span></span></h3><div class="notion-text notion-block-4d4d2cb7788b43f7bd2f3d0a0be0d7ed"><b>42. 接雨水</b></div><div class="notion-text notion-block-76f36f8a6be04136b523a1b6fc125308"><b><a class="notion-link" href="https://leetcode.cn/problems/trapping-rain-water/" target="_blank" rel="noopener noreferrer">力扣题目链接</a></b></div><div class="notion-text notion-block-ddd8b90313b54d9b88dd2a8cf8e0353a"><b>84.柱状图中最大的矩形</b></div><div class="notion-text notion-block-f150b2bfeec4438495d9bc7b05dffa6a"><b><a class="notion-link" href="https://leetcode.cn/problems/largest-rectangle-in-histogram/" target="_blank" rel="noopener noreferrer">力扣题目链接</a></b></div><div class="notion-text notion-block-3fa7b5dea298482a83ca314c96f9f08e">这两道题看似与单调栈无关，实则有关。需要计算的是中间的凹槽或凸出部分。在实际遇到问题时，可以仔细推演一下：栈中何时应存放元素，如何比较当前元素，以及如何计算答案。解决这几个问题后，即可进行作答。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-e0cd6abc3fb44d8a91b5bfa10b267a85" data-id="e0cd6abc3fb44d8a91b5bfa10b267a85"><span><div id="e0cd6abc3fb44d8a91b5bfa10b267a85" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e0cd6abc3fb44d8a91b5bfa10b267a85" title="📝图论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝图论</span></span></h2><div class="notion-text notion-block-146f4c47e5524ed789b869c3a36bebf5">什么时候该想起用图论的相关算法解决问题呢？</div><div class="notion-text notion-block-7355e33a54814aa0b5d0424705728259">之前我们说过，链表、数组、双指针、树的题目都有着明确的特征，图的题目同样也是。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-d0e078459cf5496d8d2cf9cd86419742" data-id="d0e078459cf5496d8d2cf9cd86419742"><span><div id="d0e078459cf5496d8d2cf9cd86419742" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d0e078459cf5496d8d2cf9cd86419742" title="DFS和BFS"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">DFS和BFS</span></span></h3><div class="notion-text notion-block-af456240a6b247fca76cf21713f854f7">DFS，也就是深度优先搜索，表示一直沿着某条路径前行，直到遇到终止条件再回溯。</div><div class="notion-text notion-block-4988b65429fa4201b6214484db0c3b03">BFS，也就是广度优先搜索，使用一个队列，将所有当前节点周围的节点全部添加进队列中。这和树的层序遍历很相似，也容易理解。</div><div class="notion-text notion-block-ef2e51dc65a84fd6b7fbc5d506ad36e1">这部分的题目很多，但基本没有难题，因为核心算法就是这两个，其他部分主要是预处理和后处理。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-23463bc981fb4d018b82351c32043b68" data-id="23463bc981fb4d018b82351c32043b68"><span><div id="23463bc981fb4d018b82351c32043b68" class="notion-header-anchor"></div><a class="notion-hash-link" href="#23463bc981fb4d018b82351c32043b68" title="📝并查集"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝并查集</span></span></h2><div class="notion-text notion-block-6b6d6b7a1776490dbc14a15e2ee9c3c0">并查集解决的问题，是判断两个元素在不在一个集合中，以及向集合中添加元素的问题，代码模板如下：</div><div class="notion-text notion-block-3488595bf7074a098579ac0d664f0342">我们可以通过一个数组来实现，数组中的每个元素即表示当前元素的根节点。如果两个节点的根节点相同，那么它们就属于同一个集合。这就像我们存储了若干棵树来表达它们的父子关系。这里的模板代码已经加入了路径压缩，也就是说树的总高度为2。</div><div class="notion-text notion-block-ef0d4febfe7342faa868192be0c10354">总之解决的还是图的问题，其中冗余连接II是难题，主要难在思路和情况分类。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-9beaefb70d4048aea6f51142b5d813ed" data-id="9beaefb70d4048aea6f51142b5d813ed"><span><div id="9beaefb70d4048aea6f51142b5d813ed" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9beaefb70d4048aea6f51142b5d813ed" title="🤗总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗总结归纳</span></span></h2><div class="notion-text notion-block-4940293b517c4fe693a425ecf4a199e3">单调栈、图论、并查集，这部分题目的核心代码就那么多，重点在于能否想到使用，以及如何使用。这很像编写应用时的工程问题，只需清楚理解情境和最终要求，细心一点，就能达到最后的目标。</div><div class="notion-blank notion-block-101634e639af48e0a37606d2fe0dc680"> </div><div class="notion-text notion-block-d9632c6583294387bdf447b449d2d17f">致谢：</div><div class="notion-callout notion-gray_background_co notion-block-8af2f1c199d84da3aef11610b3cd351c"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">Written by Aryue,editted by Notion AI.</div></div><div class="notion-blank notion-block-c81c39263e2f48b592a445980a95d01f"> </div><div class="notion-blank notion-block-c9bd9f795858430ca0c8de366520fefb"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[代码随想录—数组]]></title>
            <link>https://www.aryue.com/article/3ec348f1-81ae-4ad6-929e-007a030fa5a2</link>
            <guid>https://www.aryue.com/article/3ec348f1-81ae-4ad6-929e-007a030fa5a2</guid>
            <pubDate>Tue, 11 Apr 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[代码随想录 数组篇刷题总结]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-3ec348f181ae4ad6929e007a030fa5a2"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><blockquote class="notion-quote notion-block-8db26438531b44898314060a1cc27531"><div>本文是经过在代码随想录网站上学习和刷题，总结下来的一些思考。如有侵权，立刻删除。</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-95e3d690d0754263a6ae35a5026f9d79" data-id="95e3d690d0754263a6ae35a5026f9d79"><span><div id="95e3d690d0754263a6ae35a5026f9d79" class="notion-header-anchor"></div><a class="notion-hash-link" href="#95e3d690d0754263a6ae35a5026f9d79" title="🤔 综述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤔 综述</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-embed"><div style="height:320px;position:relative"><iframe class="notion-asset-object-fit" src="https://programmercarl.com/" title="iframe embed" frameBorder="0" loading="lazy" scrolling="auto" allowfullscreen=""></iframe></div></figure><blockquote class="notion-quote notion-block-3d774bce5eef4c4e8bdf9a494322a7d4"><div>😁薛定谔的学习：在你用到一个知识之前，它永远无用。</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-c8fe7b8e05334b3c883ec40075a5ff07" data-id="c8fe7b8e05334b3c883ec40075a5ff07"><span><div id="c8fe7b8e05334b3c883ec40075a5ff07" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c8fe7b8e05334b3c883ec40075a5ff07" title="📝数组"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝数组</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-6e47cf4d09724ff59e206214c044892b" data-id="6e47cf4d09724ff59e206214c044892b"><span><div id="6e47cf4d09724ff59e206214c044892b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6e47cf4d09724ff59e206214c044892b" title="最简单的部分，也是最不简单的部分"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">最简单的部分，也是最不简单的部分</span></span></h3><div class="notion-text notion-block-3e5ec0b740724fe7bf9802872c0efc2c">数组往往是学习算法和数据结构的第一步，因为其相较于其他内容比较简单。但这里为什么说数组也是最不简单的呢？不仅仅是因为数组这部分也有相对比较困难的题目，我认为有以下几个难点：</div><ul class="notion-list notion-list-disc notion-block-9b339183bba24f268f6f79488216c968"><li>其他所有内容，或多或少都依赖于数组</li></ul><ul class="notion-list notion-list-disc notion-block-c1b9c5064a6244a494129bb8993105aa"><li>数组能牵扯出C++刷题的一些注意事项，比如如何自行处理输入输出，C++中标准STL容器怎么用等。</li></ul><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-5d784b62c72f4b28affab89fa0602197" data-id="5d784b62c72f4b28affab89fa0602197"><span><div id="5d784b62c72f4b28affab89fa0602197" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5d784b62c72f4b28affab89fa0602197" title="正式开始"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">正式开始</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-4b58d735a3d949dc98c9ca213f392df5" data-id="4b58d735a3d949dc98c9ca213f392df5"><span><div id="4b58d735a3d949dc98c9ca213f392df5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4b58d735a3d949dc98c9ca213f392df5" title="数组的原理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">数组的原理</span></span></h4><div class="notion-text notion-block-f80ed45deced464b9b8642269e5595b9">这部分应该都很熟悉，数组就是在一段连续的内存上排列的一堆相同数据类型的数据。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d03ee1c9b4dc420b8e772fdeb3e706d5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:686px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A8ca790a4-39cc-489a-becb-a2fd47c16c49%3AUntitled.png?table=block&amp;id=d03ee1c9-b4dc-420b-8e77-2fdeb3e706d5&amp;t=d03ee1c9-b4dc-420b-8e77-2fdeb3e706d5" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-9a5198b7c5b94a5791c2428d399b4c91">至于数组插入，数组赋值等都是什么时间复杂度，这里就不说了，因为学过无数次了。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-555a5e6e4c4048098235885c119f2dc4" data-id="555a5e6e4c4048098235885c119f2dc4"><span><div id="555a5e6e4c4048098235885c119f2dc4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#555a5e6e4c4048098235885c119f2dc4" title="二维数组内存如何分布呢？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二维数组内存如何分布呢？</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-47ff8b19d1284a2c83f538c4308b695c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Afb1fd539-7c5d-4869-a0c1-8fa71cded0b7%3AUntitled.png?table=block&amp;id=47ff8b19-d128-4a2c-83f5-38c4308b695c&amp;t=47ff8b19-d128-4a2c-83f5-38c4308b695c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-8094a48339854ce8a087cbbde9c16d55">如上图，是Java中二维数组的内存分布。在不同的语言中，情况不同，C和C++中就是连续的，在上C语言或者C++课程时，总会遇到计算内存地址的相关题目。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-ea4e305f631545c3a00144d415cc5448" data-id="ea4e305f631545c3a00144d415cc5448"><span><div id="ea4e305f631545c3a00144d415cc5448" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ea4e305f631545c3a00144d415cc5448" title="Vector和Array，容器和数组"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Vector和Array，容器和数组</span></span></h4><div class="notion-text notion-block-acbcf14fc4424c1784ca182ab0e6e5e5">在C++中，按照规范的方式来划分的话，Vector应该属于容器，其底层实现是Array，还是有所区别的。</div><div class="notion-to-do notion-block-e6f42d88b5194780a98102b181d7bc0f"><div class="notion-to-do-item"><span class="notion-property notion-property-checkbox"><div class="notion-property-checkbox-unchecked"></div></span><div class="notion-to-do-body">补充Vector和Array的相关内容</div></div><div class="notion-to-do-children"></div></div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-dd8180c1969b48a3b98113ff5e13110a" data-id="dd8180c1969b48a3b98113ff5e13110a"><span><div id="dd8180c1969b48a3b98113ff5e13110a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dd8180c1969b48a3b98113ff5e13110a" title="常见题目类型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常见题目类型</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-74b6218c537b45e29621ca60fb443913" data-id="74b6218c537b45e29621ca60fb443913"><span><div id="74b6218c537b45e29621ca60fb443913" class="notion-header-anchor"></div><a class="notion-hash-link" href="#74b6218c537b45e29621ca60fb443913" title="二分查找"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二分查找</span></span></h4><div class="notion-text notion-block-9f64d0838fd648ec832c050c5ffeb42b">暴力解法时间复杂度是n，使用二分查找能做到logn。</div><div class="notion-text notion-block-3238d23f9f7941efa7e2ee3141768751">做这种类型题目时，确定好循环终结的条件就好，不要混乱，一般都能写出来。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-8b35b4913f8945ad8dab93600ea09880" data-id="8b35b4913f8945ad8dab93600ea09880"><span><div id="8b35b4913f8945ad8dab93600ea09880" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8b35b4913f8945ad8dab93600ea09880" title="双指针"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">双指针</span></span></h4><div class="notion-callout notion-gray_background_co notion-block-1cfd054f7113435e8ac9ed1ed4870c25"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="❓">❓</span></div><div class="notion-callout-text"><b><a class="notion-link" href="https://leetcode.cn/problems/remove-element/" target="_blank" rel="noopener noreferrer">力扣题目链接(opens new window)</a></b><div class="notion-text notion-block-874b89e29e0344eba49b17bffdc9f3bd">给你一个数组 nums 和一个值 val，你需要 原地 移除所有数值等于 val 的元素，并返回移除后数组的新长度。</div><div class="notion-text notion-block-6b9f0f884dac4854bbaae19ca3998bd5">不要使用额外的数组空间，你必须仅使用 O(1) 额外空间并<b>原地</b>修改输入数组。</div><div class="notion-text notion-block-02953485d88e4bb284d960a781ca1fe2">元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。</div><div class="notion-text notion-block-5969c56085f84519acd22338470cba1e">示例 1: 给定 nums = [3,2,2,3], val = 3, 函数应该返回新的长度 2, 并且 nums 中的前两个元素均为 2。 你不需要考虑数组中超出新长度后面的元素。</div><div class="notion-text notion-block-cc4b89ae1c3649f7a6ade0fc7375dc8f">示例 2: 给定 nums = [0,1,2,2,3,0,4,2], val = 2, 函数应该返回新的长度 5, 并且 nums 中的前五个元素为 0, 1, 3, 0, 4。</div></div></div><div class="notion-text notion-block-f80896925ae947f2a4643221fa61709c">这里首次引入了双指针的思想，简单来说，第一个指针找到下一个需要安放的位置，第二个指针去找适合安放的元素。</div><div class="notion-text notion-block-c24fdf780feb434a86334897aa25c2be">这里要注意，不一定双指针就一定都从左往右移，要根据具体情况具体分析。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-cecc075f185647cc91d5de13488fc3fb" data-id="cecc075f185647cc91d5de13488fc3fb"><span><div id="cecc075f185647cc91d5de13488fc3fb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cecc075f185647cc91d5de13488fc3fb" title="滑动窗口"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">滑动窗口</span></span></h4><div class="notion-text notion-block-2b7c3eeed84741db927a849b9e275fd4">这类问题比较经典，难度从低到高的都有。</div><div class="notion-text notion-block-9aa329c567f54dbbbabbc950ba6253a3"><b>滑动窗口的精妙之处在于根据当前子序列和大小的情况，不断调节子序列的起始位置。从而将O(n^2)的暴力解法降为O(n)。</b></div><div class="notion-text notion-block-7d4bdedaf3db4c9b9204f2b4dac59494">这部分就开始复杂起来了，因为我们这里面需要很好地处理窗口左右边界移动地时机，在做题时，还需要借助哈希表等容器辅助。</div><div class="notion-to-do notion-block-e57e9dd35ded4995abc231c5d1953b6a"><div class="notion-to-do-item"><span class="notion-property notion-property-checkbox"><div class="notion-property-checkbox-unchecked"></div></span><div class="notion-to-do-body">熟悉大部分的C++标准容器</div></div><div class="notion-to-do-children"></div></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-ebd5bf6eefbd4bf1ace3d0807cc41fab" data-id="ebd5bf6eefbd4bf1ace3d0807cc41fab"><span><div id="ebd5bf6eefbd4bf1ace3d0807cc41fab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ebd5bf6eefbd4bf1ace3d0807cc41fab" title="模拟行为"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>模拟行为</b></span></span></h4><div class="notion-text notion-block-39d721a6dd6548fd91b5bd133d9db660">典型题目就是leetcode上的两个螺旋矩阵问题，这部分乍一看是比较简单的，但是难就难在边界条件处理时十分头疼。在做这类题目是，头脑一定要清晰，如何遍历？如何制定统一的遍历判断，使代码编写时不容易乱，需要非常注意。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-3d7320258af34546ad22acbd5f1e671b" data-id="3d7320258af34546ad22acbd5f1e671b"><span><div id="3d7320258af34546ad22acbd5f1e671b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3d7320258af34546ad22acbd5f1e671b" title="🤗总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗总结归纳</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b122263cfa814eb68ab007e5c8f965ba"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ac6aacc98-fe9e-44c3-9cd8-8f9312d11285%3AUntitled.png?table=block&amp;id=b122263c-fa81-4eb6-8ab0-07e5c8f965ba&amp;t=b122263c-fa81-4eb6-8ab0-07e5c8f965ba" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-c1b7b0c65c104fa8b1f8076412687105">刷完这部分题目，日程安排上需要加入两个新的内容，一个是如何自行处理输入输出；一个是重新拾回数据结构，并熟悉C++、C#中常见的容器及其实现原理。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a780920499cd4481b3c6681197d56df9"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ad2174841-de15-4b02-a2ce-048d4368a853%3AUntitled.png?table=block&amp;id=a7809204-99cd-4481-b3c6-681197d56df9&amp;t=a7809204-99cd-4481-b3c6-681197d56df9" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-callout notion-gray_background_co notion-block-082ed68cb5a34cce8aff40290d0e890c"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">Written by Aryue，editted by Notion AI. </div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[代码随想录—动态规划]]></title>
            <link>https://www.aryue.com/article/664ce565-0875-4414-98f2-ea3ac954c1e9</link>
            <guid>https://www.aryue.com/article/664ce565-0875-4414-98f2-ea3ac954c1e9</guid>
            <pubDate>Thu, 31 Aug 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[代码随想录 动态规划总结]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-664ce5650875441498f2ea3ac954c1e9"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><blockquote class="notion-quote notion-block-53d0344596294a6c9b44dccdcc196e03"><div>本文是经过在代码随想录网站上学习和刷题，总结下来的一些思考。如有侵权，立刻删除。</div></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-d190fa20b3e144bbb91494d4ad5f91b8" data-id="d190fa20b3e144bbb91494d4ad5f91b8"><span><div id="d190fa20b3e144bbb91494d4ad5f91b8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d190fa20b3e144bbb91494d4ad5f91b8" title="🤔 综述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤔 综述</span></span></h2><div class="notion-text notion-block-a01eb717fa5a41fdad13d114b1b9cc18">动态规划部分的题目类型多、难度较高，需要刷题时格外注意体会思路。</div><div class="notion-text notion-block-8e4cc3f32e4d4682878e0f8120f0d666">现总结动态规划五部曲如下：</div><ol start="1" class="notion-list notion-list-numbered notion-block-e905d3ebec1941e697fbdd048b68fea6" style="list-style-type:decimal"><li>确定dp数组（dp table）以及下标的含义</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2edc4461c6784de4bc8bc6d1c52c542c" style="list-style-type:decimal"><li>确定递推公式</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-3f13dca364f5425a9bc501017190ab2b" style="list-style-type:decimal"><li>dp数组如何初始化</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-8297e70958dc4790aec9bd9310a2e87b" style="list-style-type:decimal"><li>确定遍历顺序</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-b9b6fe2a46644bec9a470f644b47f489" style="list-style-type:decimal"><li>举例推导dp数组</li></ol><div class="notion-text notion-block-202eeb1828f448cf8c2de6b34b98c93c">其中，最困难的实际上是第三步和第四步。当我们遇到一个问题时，如果我们能确定要使用动态规划方法来解决，那么说明我们已经对状态如何转移和推导有了一个模糊的认识，而dp数组无非就是一维、二维两种情况，分别去思考如何定义合理即可。</div><div class="notion-text notion-block-c4cceb550f4840dfaf81f884277e6eea">最难的部分是初始化和遍历。我们需要知道dp数组中下一个元素的来源，以推导出它。如果dp[i][j]由左上角的元素推出，那么遍历顺序一定是从上往下，从左往右；如果dp[i][j]由下方和左边的元素推出，那么遍历顺序一定是由下往上，从左往右，依次类推。</div><div class="notion-text notion-block-9e9ee0b0dc5d41fdb1c630190b3a1327">建议在没有思路的时候，打开本地的控制台程序，将自己推导的公式打印出来看看，理清思路。可以借此机会练习一下ACM模式。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-06f16fc745d54b92a2c7d01a22492130" data-id="06f16fc745d54b92a2c7d01a22492130"><span><div id="06f16fc745d54b92a2c7d01a22492130" class="notion-header-anchor"></div><a class="notion-hash-link" href="#06f16fc745d54b92a2c7d01a22492130" title="📝动态规划"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📝动态规划</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1de968286c52456f9fba96ec3717bcee" data-id="1de968286c52456f9fba96ec3717bcee"><span><div id="1de968286c52456f9fba96ec3717bcee" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1de968286c52456f9fba96ec3717bcee" title="题型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">题型</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-244fe316d08f4c649366b48afbd6051f" data-id="244fe316d08f4c649366b48afbd6051f"><span><div id="244fe316d08f4c649366b48afbd6051f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#244fe316d08f4c649366b48afbd6051f" title="动态规划基础"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">动态规划基础</span></span></h4><div class="notion-text notion-block-1cc120b336984c3fb1da6afe68fa945e">很容易掌握的一些题目，复习时简单看下即可。</div><ul class="notion-list notion-list-disc notion-block-176e8b3db3ea4ba9bec1fd8797d10619"><li><b><a class="notion-link" href="https://programmercarl.com/%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.html" target="_blank" rel="noopener noreferrer">关于动态规划，你该了解这些！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-2af492ef15454104a1e764a9b6476efb"><li><b><a class="notion-link" href="https://programmercarl.com/0509.%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0.html" target="_blank" rel="noopener noreferrer">动态规划：斐波那契数(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-3c8ff924cc054984870f547cd74e7349"><li><b><a class="notion-link" href="https://programmercarl.com/0070.%E7%88%AC%E6%A5%BC%E6%A2%AF.html" target="_blank" rel="noopener noreferrer">动态规划：爬楼梯(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-b843146627e34a63952247f95856491c"><li><b><a class="notion-link" href="https://programmercarl.com/0746.%E4%BD%BF%E7%94%A8%E6%9C%80%E5%B0%8F%E8%8A%B1%E8%B4%B9%E7%88%AC%E6%A5%BC%E6%A2%AF.html" target="_blank" rel="noopener noreferrer">动态规划：使用最小花费爬楼梯(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-f48caaca96dc496ea51c6d6c9517f9d9"><li><b><a class="notion-link" href="https://programmercarl.com/0062.%E4%B8%8D%E5%90%8C%E8%B7%AF%E5%BE%84.html" target="_blank" rel="noopener noreferrer">动态规划：不同路径(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-786d10af9b4b47a58d5cc6fa692d1f62"><li><b><a class="notion-link" href="https://programmercarl.com/0063.%E4%B8%8D%E5%90%8C%E8%B7%AF%E5%BE%84II.html" target="_blank" rel="noopener noreferrer">动态规划：不同路径还不够，要有障碍！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-528b31f2894c4c9a8541b7f9c402cbe6"><li><b><a class="notion-link" href="https://programmercarl.com/0343.%E6%95%B4%E6%95%B0%E6%8B%86%E5%88%86.html" target="_blank" rel="noopener noreferrer">动态规划：整数拆分，你要怎么拆？(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-afe43b856e62491e8fa0e6d58003a2e8"><li><b><a class="notion-link" href="https://programmercarl.com/0096.%E4%B8%8D%E5%90%8C%E7%9A%84%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.html" target="_blank" rel="noopener noreferrer">动态规划：不同的二叉搜索树</a></b></li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-f4651f6a6fe24344bb8a436a657d5ddb" data-id="f4651f6a6fe24344bb8a436a657d5ddb"><span><div id="f4651f6a6fe24344bb8a436a657d5ddb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f4651f6a6fe24344bb8a436a657d5ddb" title="背包问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">背包问题</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-4a3aaf6224c04a0fa0568f51c9199862"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A3cc8ce08-1b65-4c8a-8220-ef71e3c8ad21%3AUntitled.png?table=block&amp;id=4a3aaf62-24c0-4a0f-a056-8f51c9199862&amp;t=4a3aaf62-24c0-4a0f-a056-8f51c9199862" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-e66664c3a7b14af2bcaf6697806aa5b3"><li><b><a class="notion-link" href="https://programmercarl.com/%E8%83%8C%E5%8C%85%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%8001%E8%83%8C%E5%8C%85-1.html" target="_blank" rel="noopener noreferrer">动态规划：关于01背包问题，你该了解这些！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-96b6cdb850b44d55b547ec40ccc706aa"><li><b><a class="notion-link" href="https://programmercarl.com/%E8%83%8C%E5%8C%85%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%8001%E8%83%8C%E5%8C%85-2.html" target="_blank" rel="noopener noreferrer">动态规划：关于01背包问题，你该了解这些！（滚动数组）(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-b731834843cc4e4aa38b338c9abf1826"><li><b><a class="notion-link" href="https://programmercarl.com/0416.%E5%88%86%E5%89%B2%E7%AD%89%E5%92%8C%E5%AD%90%E9%9B%86.html" target="_blank" rel="noopener noreferrer">动态规划：分割等和子集可以用01背包！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-16d35e13af0e437ca7cb28432ee83f76"><li><b><a class="notion-link" href="https://programmercarl.com/1049.%E6%9C%80%E5%90%8E%E4%B8%80%E5%9D%97%E7%9F%B3%E5%A4%B4%E7%9A%84%E9%87%8D%E9%87%8FII.html" target="_blank" rel="noopener noreferrer">动态规划：最后一块石头的重量 II(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-a691ebd0951e4ca28955f9e7f472eabc"><li><b><a class="notion-link" href="https://programmercarl.com/0494.%E7%9B%AE%E6%A0%87%E5%92%8C.html" target="_blank" rel="noopener noreferrer">动态规划：目标和！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-bdf6b8c0076f4cecae4460c99059c969"><li><b><a class="notion-link" href="https://programmercarl.com/0474.%E4%B8%80%E5%92%8C%E9%9B%B6.html" target="_blank" rel="noopener noreferrer">动态规划：一和零！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-4f3d73f49e974da8ab79425793845c80"><li><b><a class="notion-link" href="https://programmercarl.com/%E8%83%8C%E5%8C%85%E9%97%AE%E9%A2%98%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80%E5%AE%8C%E5%85%A8%E8%83%8C%E5%8C%85.html" target="_blank" rel="noopener noreferrer">动态规划：关于完全背包，你该了解这些！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-f4995b36ea1d44fe909045c7db968e31"><li><b><a class="notion-link" href="https://programmercarl.com/0518.%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2II.html" target="_blank" rel="noopener noreferrer">动态规划：给你一些零钱，你要怎么凑？(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-621984188c094bbb81257a1636da6aed"><li><b><a class="notion-link" href="https://programmercarl.com/0377.%E7%BB%84%E5%90%88%E6%80%BB%E5%92%8C%E2%85%A3.html" target="_blank" rel="noopener noreferrer">动态规划：Carl称它为排列总和！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-3bbb146ec975451395f54b28053f5e6f"><li><b><a class="notion-link" href="https://programmercarl.com/0070.%E7%88%AC%E6%A5%BC%E6%A2%AF%E5%AE%8C%E5%85%A8%E8%83%8C%E5%8C%85%E7%89%88%E6%9C%AC.html" target="_blank" rel="noopener noreferrer">动态规划：以前我没得选，现在我选择再爬一次！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-7b688875626148c790590604a387d118"><li><b><a class="notion-link" href="https://programmercarl.com/0322.%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2.html" target="_blank" rel="noopener noreferrer">动态规划： 给我个机会，我再兑换一次零钱(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-85159c6ad9c94239997d76062c3dfb39"><li><b><a class="notion-link" href="https://programmercarl.com/0279.%E5%AE%8C%E5%85%A8%E5%B9%B3%E6%96%B9%E6%95%B0.html" target="_blank" rel="noopener noreferrer">动态规划：一样的套路，再求一次完全平方数(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-ca7519425596449c9a848b8050d765b0"><li><b><a class="notion-link" href="https://programmercarl.com/0139.%E5%8D%95%E8%AF%8D%E6%8B%86%E5%88%86.html" target="_blank" rel="noopener noreferrer">动态规划：单词拆分(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-588f2d50d51d446c9e3df64701d750e5"><li><b><a class="notion-link" href="https://programmercarl.com/%E8%83%8C%E5%8C%85%E9%97%AE%E9%A2%98%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80%E5%A4%9A%E9%87%8D%E8%83%8C%E5%8C%85.html" target="_blank" rel="noopener noreferrer">动态规划：关于多重背包，你该了解这些！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-9119a82d8d914320a5f9cad7c0f34693"><li><b><a class="notion-link" href="https://programmercarl.com/%E8%83%8C%E5%8C%85%E6%80%BB%E7%BB%93%E7%AF%87.html" target="_blank" rel="noopener noreferrer">听说背包问题很难？ 这篇总结篇来拯救你了(opens new window)</a></b></li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-cefceefb89d64e769317f710cc8499cd" data-id="cefceefb89d64e769317f710cc8499cd"><span><div id="cefceefb89d64e769317f710cc8499cd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cefceefb89d64e769317f710cc8499cd" title="打家劫舍系列"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>打家劫舍系列</b></span></span></h4><div class="notion-text notion-block-d4ecddaab050436b9df91b2b0d0314a4">这个系列很有意思，也不难，</div><ul class="notion-list notion-list-disc notion-block-92c10032a4a3445fb96259bfde4f6f70"><li><b><a class="notion-link" href="https://programmercarl.com/0198.%E6%89%93%E5%AE%B6%E5%8A%AB%E8%88%8D.html" target="_blank" rel="noopener noreferrer">动态规划：开始打家劫舍！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-53097c1250754d93bb22e03ef760776d"><li><b><a class="notion-link" href="https://programmercarl.com/0213.%E6%89%93%E5%AE%B6%E5%8A%AB%E8%88%8DII.html" target="_blank" rel="noopener noreferrer">动态规划：继续打家劫舍！(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-a3830fbfa5514a9592b8521c212adf6c"><li><b><a class="notion-link" href="https://programmercarl.com/0337.%E6%89%93%E5%AE%B6%E5%8A%AB%E8%88%8DIII.html" target="_blank" rel="noopener noreferrer">动态规划：还要打家劫舍！</a></b></li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-19a42344b96e45cb96e815f17613ca48" data-id="19a42344b96e45cb96e815f17613ca48"><span><div id="19a42344b96e45cb96e815f17613ca48" class="notion-header-anchor"></div><a class="notion-hash-link" href="#19a42344b96e45cb96e815f17613ca48" title="股票系列"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>股票系列</b></span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-df59fb6b2bd44f88a01a83bd827cd353"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A23ad51cf-3928-4732-86c3-cd7561a2231d%3AUntitled.png?table=block&amp;id=df59fb6b-2bd4-4f88-a01a-83bd827cd353&amp;t=df59fb6b-2bd4-4f88-a01a-83bd827cd353" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-988a212b89864e24ac90e9cb5397fbc5"><li><b><a class="notion-link" href="https://programmercarl.com/0121.%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA.html" target="_blank" rel="noopener noreferrer">动态规划：买卖股票的最佳时机(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-69dca1db5b5d40c4a43f4275665a2307"><li><b><a class="notion-link" href="https://programmercarl.com/%E5%91%A8%E6%80%BB%E7%BB%93/20210225%E5%8A%A8%E8%A7%84%E5%91%A8%E6%9C%AB%E6%80%BB%E7%BB%93.html" target="_blank" rel="noopener noreferrer">动态规划：本周我们都讲了这些（系列六）(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-82fc1691a52e41f38982cd1cdceaf4d9"><li><b><a class="notion-link" href="https://programmercarl.com/0122.%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BAII%EF%BC%88%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%EF%BC%89.html" target="_blank" rel="noopener noreferrer">动态规划：买卖股票的最佳时机II(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-7b7c906cdfb446e1827597e0f163b5ef"><li><b><a class="notion-link" href="https://programmercarl.com/0123.%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BAIII.html" target="_blank" rel="noopener noreferrer">动态规划：买卖股票的最佳时机III(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-eb1d231519f9423b8fb1a7542faa84df"><li><b><a class="notion-link" href="https://programmercarl.com/0188.%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BAIV.html" target="_blank" rel="noopener noreferrer">动态规划：买卖股票的最佳时机IV(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-c3fd40881d8242dab40b1c7d29415f33"><li><b><a class="notion-link" href="https://programmercarl.com/0309.%E6%9C%80%E4%BD%B3%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E6%97%B6%E6%9C%BA%E5%90%AB%E5%86%B7%E5%86%BB%E6%9C%9F.html" target="_blank" rel="noopener noreferrer">动态规划：最佳买卖股票时机含冷冻期(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-ee146dd50c164950a9b4d8e2624b43b2"><li><b><a class="notion-link" href="https://programmercarl.com/%E5%91%A8%E6%80%BB%E7%BB%93/20210304%E5%8A%A8%E8%A7%84%E5%91%A8%E6%9C%AB%E6%80%BB%E7%BB%93.html" target="_blank" rel="noopener noreferrer">动态规划：本周我们都讲了这些（系列七）(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-2b80f8004558494489e57dbf90e4005b"><li><b><a class="notion-link" href="https://programmercarl.com/0714.%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA%E5%90%AB%E6%89%8B%E7%BB%AD%E8%B4%B9%EF%BC%88%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%EF%BC%89.html" target="_blank" rel="noopener noreferrer">动态规划：买卖股票的最佳时机含手续费(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-85e71488f0e048c198fbb1b7c5df9d07"><li><b><a class="notion-link" href="https://programmercarl.com/%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92-%E8%82%A1%E7%A5%A8%E9%97%AE%E9%A2%98%E6%80%BB%E7%BB%93%E7%AF%87.html" target="_blank" rel="noopener noreferrer">动态规划：股票系列总结篇</a></b></li></ul><div class="notion-text notion-block-94fba561251a4380a1df1d562fe88688">股票系列问题也不是很难，可以简单复习下。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-224959c1bfb94041b656a674dd6641a5" data-id="224959c1bfb94041b656a674dd6641a5"><span><div id="224959c1bfb94041b656a674dd6641a5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#224959c1bfb94041b656a674dd6641a5" title="子序列系列"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>子序列系列</b></span></span></h4><div class="notion-text notion-block-e383ee6dcefa489fa903519c93e0807b">这个部分的一些题目是相当难的，一刷基本上已经放弃了，回头再说吧。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9be9eb20fdfe4bea885ca2652d584a08"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A8121c330-45ca-41b2-84a5-703365d55bb8%3AUntitled.png?table=block&amp;id=9be9eb20-fdfe-4bea-885c-a2652d584a08&amp;t=9be9eb20-fdfe-4bea-885c-a2652d584a08" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-4ec8446f714740b48c878e1362c432b6"><li><b><a class="notion-link" href="https://programmercarl.com/0300.%E6%9C%80%E9%95%BF%E4%B8%8A%E5%8D%87%E5%AD%90%E5%BA%8F%E5%88%97.html" target="_blank" rel="noopener noreferrer">动态规划：最长递增子序列(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-77cb7af44c1c4aaaac4b2f8abf6ad367"><li><b><a class="notion-link" href="https://programmercarl.com/0674.%E6%9C%80%E9%95%BF%E8%BF%9E%E7%BB%AD%E9%80%92%E5%A2%9E%E5%BA%8F%E5%88%97.html" target="_blank" rel="noopener noreferrer">动态规划：最长连续递增序列(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-db1d2d5f9bb64c55a7b07f1ec8af5c82"><li><b><a class="notion-link" href="https://programmercarl.com/0718.%E6%9C%80%E9%95%BF%E9%87%8D%E5%A4%8D%E5%AD%90%E6%95%B0%E7%BB%84.html" target="_blank" rel="noopener noreferrer">动态规划：最长重复子数组(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-9dcc295b506541c18f7c9d6d23c3fe6e"><li><b><a class="notion-link" href="https://programmercarl.com/1143.%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%AD%90%E5%BA%8F%E5%88%97.html" target="_blank" rel="noopener noreferrer">动态规划：最长公共子序列(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-ec376aee9557451fb427c0500d0264bc"><li><b><a class="notion-link" href="https://programmercarl.com/1035.%E4%B8%8D%E7%9B%B8%E4%BA%A4%E7%9A%84%E7%BA%BF.html" target="_blank" rel="noopener noreferrer">动态规划：不相交的线(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-0093d3b134434dba9fa77a4ce1b23bf7"><li><b><a class="notion-link" href="https://programmercarl.com/0053.%E6%9C%80%E5%A4%A7%E5%AD%90%E5%BA%8F%E5%92%8C%EF%BC%88%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%EF%BC%89.html" target="_blank" rel="noopener noreferrer">动态规划：最大子序和(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-5c2fb1bdfcf1448bb3c2f9ffa3f6e3ad"><li><b><a class="notion-link" href="https://programmercarl.com/0392.%E5%88%A4%E6%96%AD%E5%AD%90%E5%BA%8F%E5%88%97.html" target="_blank" rel="noopener noreferrer">动态规划：判断子序列(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-b8001ec07cbe4f5ba77931bdea32acd2"><li><b><a class="notion-link" href="https://programmercarl.com/0115.%E4%B8%8D%E5%90%8C%E7%9A%84%E5%AD%90%E5%BA%8F%E5%88%97.html" target="_blank" rel="noopener noreferrer">动态规划：不同的子序列(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-8aa9ce6671824c729c0f5a4d7c9d215f"><li><b><a class="notion-link" href="https://programmercarl.com/0583.%E4%B8%A4%E4%B8%AA%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E5%88%A0%E9%99%A4%E6%93%8D%E4%BD%9C.html" target="_blank" rel="noopener noreferrer">动态规划：两个字符串的删除操作(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-f3f14bf388ee4db785bfcc782c25814e"><li><b><a class="notion-link" href="https://programmercarl.com/0072.%E7%BC%96%E8%BE%91%E8%B7%9D%E7%A6%BB.html" target="_blank" rel="noopener noreferrer">动态规划：编辑距离(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-7e580399bef643fa9856647009fbade1"><li><b><a class="notion-link" href="https://programmercarl.com/%E4%B8%BA%E4%BA%86%E7%BB%9D%E6%9D%80%E7%BC%96%E8%BE%91%E8%B7%9D%E7%A6%BB%EF%BC%8C%E5%8D%A1%E5%B0%94%E5%81%9A%E4%BA%86%E4%B8%89%E6%AD%A5%E9%93%BA%E5%9E%AB.html" target="_blank" rel="noopener noreferrer">为了绝杀编辑距离，我做了三步铺垫，你都知道么？(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-4bce7ca5ad184a45a9a9dfd7fff099de"><li><b><a class="notion-link" href="https://programmercarl.com/0647.%E5%9B%9E%E6%96%87%E5%AD%90%E4%B8%B2.html" target="_blank" rel="noopener noreferrer">动态规划：回文子串(opens new window)</a></b></li></ul><ul class="notion-list notion-list-disc notion-block-b24d03e40e33456e99bdd07694d8eb51"><li><b><a class="notion-link" href="https://programmercarl.com/0516.%E6%9C%80%E9%95%BF%E5%9B%9E%E6%96%87%E5%AD%90%E5%BA%8F%E5%88%97.html" target="_blank" rel="noopener noreferrer">动态规划：最长回文子序列</a></b></li></ul><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-d3d81242db1141a184b7392ac7b08af5" data-id="d3d81242db1141a184b7392ac7b08af5"><span><div id="d3d81242db1141a184b7392ac7b08af5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d3d81242db1141a184b7392ac7b08af5" title="贪心与动态规划"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">贪心与动态规划</span></span></h2><div class="notion-text notion-block-02a1d5ef09674c12b40ed4aac66d2d81">当遇到回溯算法、动态规划和贪心算法相关的题目时，你会明显感觉到它们与之前的题目有所不同。</div><div class="notion-text notion-block-7c2a07b7486f416f83c740e319298598">这是因为这些题目开始更密切地与现实情境结合，而且往往是各大公司主要考察的题目。</div><div class="notion-text notion-block-945fa864d57d4d749da20b5a1a201036">因此，当遇到这类题目时，你可以花费1-2分钟按照以下的思路尝试解题：</div><ul class="notion-list notion-list-disc notion-block-e281db0228064671a59335f3ee70b4c8"><li>暴力算法（如果在使用暴力算法过程中，发现连嵌套循环的次数都无法确定，那么大概率是回溯算法，因为回溯算法的时间复杂度通常是指数级）</li></ul><ul class="notion-list notion-list-disc notion-block-8d1a66e1210f46aaa10597f5f453145b"><li>贪心算法（如果能够聪明地解决问题）</li></ul><ul class="notion-list notion-list-disc notion-block-2f205f62e3604b2a962534d3fa24ce6f"><li>动态规划（如果能将问题划分为一系列小问题，这是一种数学思想）</li></ul><div class="notion-text notion-block-4d3496e5864745188cb56bb40efe55af">基本上这样就能找到解题的思路，接下来就是如何实施这五部曲的问题了。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-506a24bd56704f599dd86850743d6a0c" data-id="506a24bd56704f599dd86850743d6a0c"><span><div id="506a24bd56704f599dd86850743d6a0c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#506a24bd56704f599dd86850743d6a0c" title="🤗总结归纳"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🤗总结归纳</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ac522e39b8454950baeb3c0891e51224"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Af779584f-ceed-4b00-bc6c-23322667f1ad%3AUntitled.png?table=block&amp;id=ac522e39-b845-4950-baeb-3c0891e51224&amp;t=ac522e39-b845-4950-baeb-3c0891e51224" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1869a6195a32435cbba607ed60593165">需要感谢<a class="notion-link" href="https://programmercarl.com/" target="_blank" rel="noopener noreferrer">代码随想录</a>，刷完这一部分的题目后，基本上就可以宣布告一段落了。这个刷题顺序还是比较不错的，非常感谢前人做的一系列总结和归纳，让后来者在刷题时减少了许多试错成本。</div><div class="notion-blank notion-block-8c5d94ba20254608890c647031688dcd"> </div><div class="notion-text notion-block-5cfcc0793d464a5fb7fc37954cfe100d">致谢：</div><div class="notion-callout notion-gray_background_co notion-block-655ebcb626d84c4c8e51ebdac63f6c0d"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">Written by Aryue,editted by Notion AI.</div></div><div class="notion-blank notion-block-76e92353b2664f71bc264ac4266036a1"> </div><div class="notion-blank notion-block-e0e98b27b7b54123bc52b8dbbfd421b6"> </div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>