[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"public:announcements":3,"footer:categories:zh":4,"public:navigations:zh":132,"post:detail:post-22-算法与数据结构动态:zh":177},[],[5,23,39,55,71,88,103,117],{"id":6,"name":7,"slug":12,"description":13,"icon":18,"color":19,"cover_image":20,"created_at":21,"post_count":22},1,{"en":8,"ja":9,"zh":10,"zh_Hant":11},"Technology","テクノロジー","技术","技術","technology",{"en":14,"ja":15,"zh":16,"zh_Hant":17},"Cutting-edge technology exploration and in-depth analysis covering programming languages, frameworks, and architecture design","プログラミング言語、フレームワーク、アーキテクチャ設計を含む先端技術の探究","前沿技术探索与深度分析，涵盖编程语言、框架、架构设计等核心领域","前沿技術探索與深度分析，涵蓋編程語言、框架、架構設計等核心領域","heroicons:cog-6-tooth","#6366f1",null,"2026-09-30T18:09:53.633610Z",8,{"id":24,"name":25,"slug":29,"description":30,"icon":35,"color":36,"cover_image":20,"created_at":37,"post_count":38},2,{"en":26,"ja":27,"zh":28,"zh_Hant":28},"Tutorial","チュートリアル","教程","tutorial",{"en":31,"ja":32,"zh":33,"zh_Hant":34},"Hands-on tutorials from scratch with clear steps and complete code for developers at all levels","ゼロから始める実践的なチュートリアル。明確な手順と完全なコードで、全てのレベルの開発者に最適","从零开始的实战教程，步骤清晰，代码完整，适合各阶段开发者学习","從零開始的實戰教程，步驟清晰，代碼完整，適合各階段開發者學習","heroicons:academic-cap","#10b981","2026-09-30T18:09:53.641581Z",6,{"id":40,"name":41,"slug":45,"description":46,"icon":51,"color":52,"cover_image":20,"created_at":53,"post_count":54},3,{"en":42,"ja":43,"zh":44,"zh_Hant":44},"Frontend","フロントエンド","前端","frontend",{"en":47,"ja":48,"zh":49,"zh_Hant":50},"Full coverage of web frontend development including Vue, React, new CSS features, and performance optimization","Vue、React、CSSの新機能やパフォーマンス最適化を含むWebフロントエンド開発の全領域","Web前端开发全栈覆盖，包括Vue、React、CSS新特性及性能优化等话题","Web前端開發全棧覆蓋，包括Vue、React、CSS新特性及性能優化等話題","heroicons:computer-desktop","#ec4899","2026-09-30T18:09:53.644838Z",7,{"id":56,"name":57,"slug":62,"description":63,"icon":68,"color":69,"cover_image":20,"created_at":70,"post_count":40},4,{"en":58,"ja":59,"zh":60,"zh_Hant":61},"Backend","バックエンド","后端","後端","backend",{"en":64,"ja":65,"zh":66,"zh_Hant":67},"Server-side development best practices including API design, database optimization, and microservices architecture","API設計、データベース最適化、マイクロサービスアーキテクチャを含むサーバーサイド開発の実践","服务端开发实战经验，API设计、数据库优化、微服务架构等深度内容","服務端開發實戰經驗，API設計、數據庫優化、微服務架構等深度內容","heroicons:server-stack","#f59e0b","2026-09-30T18:09:53.647836Z",{"id":72,"name":73,"slug":78,"description":79,"icon":84,"color":85,"cover_image":20,"created_at":86,"post_count":87},5,{"en":74,"ja":75,"zh":76,"zh_Hant":77},"Fullstack","フルスタック","全栈","全棧","fullstack",{"en":80,"ja":81,"zh":82,"zh_Hant":83},"End-to-end development guides covering the full project lifecycle and technology stack selection","フロントエンドからバックエンドまでの開発プロセス全体をカバーするガイド","从前端到后端的全流程开发指南，覆盖完整项目生命周期与技术选型","從前端到後端的全流程開發指南，覆蓋完整項目生命週期與技術選型","heroicons:swatch","#8b5cf6","2026-09-30T18:09:53.650513Z",0,{"id":38,"name":89,"slug":94,"description":95,"icon":100,"color":101,"cover_image":20,"created_at":102,"post_count":56},{"en":90,"ja":91,"zh":92,"zh_Hant":93},"Essays","エッセイ","随笔","隨筆","essays",{"en":96,"ja":97,"zh":98,"zh_Hant":99},"Technical reflections and development insights recording the programmer's growth journey","プログラマーの成長の軌跡を記録する技術的考察と開発の洞察","技术思考与开发心得分享，记录程序员成长路上的点滴感悟","技術思考與開發心得分享，記錄程序員成長路上的點滴感悟","heroicons:pencil-square","#f43f5e","2026-09-30T18:09:53.653105Z",{"id":54,"name":104,"slug":108,"description":109,"icon":114,"color":115,"cover_image":20,"created_at":116,"post_count":56},{"en":105,"ja":106,"zh":107,"zh_Hant":107},"Tools","ツール","工具","tools",{"en":110,"ja":111,"zh":112,"zh_Hant":113},"Development toolchain and productivity tool recommendations to supercharge your development experience","開発効率を飛躍的に向上させるツールチェーンと生産性ツールの推奨","开发工具链与效率提升利器推荐，让你的开发体验如虎添翼","開發工具鏈與效率提升利器推薦，讓你的開發體驗如虎添翼","heroicons:wrench-screwdriver","#06b6d4","2026-09-30T18:09:53.655605Z",{"id":22,"name":118,"slug":123,"description":124,"icon":129,"color":130,"cover_image":20,"created_at":131,"post_count":87},{"en":119,"ja":120,"zh":121,"zh_Hant":122},"Translation","翻訳","翻译","翻譯","translation",{"en":125,"ja":126,"zh":127,"zh_Hant":128},"Curated translations of high-quality foreign technical articles to keep up with international trends","国際的な技術トレンドを追うための厳選された海外技術記事の翻訳","优质外文技术文章精选翻译，紧跟国际技术前沿动态","優質外文技術文章精選翻譯，緊跟國際技術前沿動態","heroicons:language","#84cc16","2026-09-30T18:09:53.658041Z",[133,144,150,157,164,171],{"id":6,"title":134,"url":139,"icon":20,"parent_id":20,"location":140,"order":6,"is_active":141,"target_blank":142,"created_at":143,"updated_at":20},{"zh":135,"en":136,"ja":137,"zh_TW":138},"首页","Home","ホーム","首頁","\u002F","header",true,false,"2026-09-30T18:09:54.251095Z",{"id":24,"title":145,"url":149,"icon":20,"parent_id":20,"location":140,"order":24,"is_active":141,"target_blank":142,"created_at":143,"updated_at":20},{"zh":146,"en":147,"ja":148,"zh_TW":146},"文章","Posts","記事","\u002Fposts",{"id":40,"title":151,"url":156,"icon":20,"parent_id":20,"location":140,"order":40,"is_active":141,"target_blank":142,"created_at":143,"updated_at":20},{"zh":152,"en":153,"ja":154,"zh_TW":155},"分类","Categories","カテゴリー","分類","\u002Fcategories",{"id":56,"title":158,"url":163,"icon":20,"parent_id":20,"location":140,"order":56,"is_active":141,"target_blank":142,"created_at":143,"updated_at":20},{"zh":159,"en":160,"ja":161,"zh_TW":162},"标签","Tags","タグ","標籤","\u002Ftags",{"id":72,"title":165,"url":170,"icon":20,"parent_id":20,"location":140,"order":72,"is_active":141,"target_blank":142,"created_at":143,"updated_at":20},{"zh":166,"en":167,"ja":168,"zh_TW":169},"关于","About","概要","關於","\u002Fpage\u002Fabout",{"id":38,"title":172,"url":176,"icon":20,"parent_id":20,"location":140,"order":38,"is_active":141,"target_blank":142,"created_at":143,"updated_at":20},{"zh":173,"en":174,"ja":175,"zh_TW":173},"留言板","Guestbook","ゲストブック","\u002Fpage\u002Fguestbook",{"id":178,"title":179,"subtitle":20,"slug":180,"source":181,"source_url":20,"audio":20,"video":20,"video_url":20,"content":182,"excerpt":183,"cover_image":20,"author":184,"category":187,"tags":188,"status":211,"visibility":212,"password":20,"views":213,"likes_count":87,"is_pinned":142,"allow_comments":141,"comments_count":56,"is_password_protected":142,"meta_title":179,"meta_description":183,"meta_keywords":214,"created_at":215,"published_at":215,"updated_at":216,"reading_time":6},22,"算法与数据结构：动态规划 5 大解题模板","post-22-算法与数据结构动态","原创","# 算法与数据结构：动态规划 5 大解题模板\n\n动态规划是算法面试中区分度最高的题型，核心思想是把大问题拆为重叠子问题、存储中间结果避免重复计算。掌握通用五步法加五类高频模板，90%的 DP 题都能解。\n\n## 通用五步法与背包类\n\n五步：① 状态定义 dp[i][j] 含义 ② 转移方程（找最后一步两种选择）③ 初始化 base case ④ 遍历顺序 ⑤ 滚动数组空间优化。01 背包每个物品选\u002F不选，容量倒序；完全背包物品可多次选，容量正序。\n\n```python\n```python\nfrom functools import lru_cache\nfrom typing import List\nimport bisect\n\ndef t1_01_knapsack(cap: int, ws: List[int], vs: List[int]) -> int:\n    n = len(ws); dp = [0] * (cap + 1)\n    for i in range(n):\n        for c in range(cap, ws[i] - 1, -1):\n            dp[c] = max(dp[c], dp[c - ws[i]] + vs[i])\n    return dp[cap]\n\ndef t2_unbounded_knapsack(cap: int, ws: List[int], vs: List[int]) -> int:\n    dp = [0] * (cap + 1)\n    for c in range(1, cap + 1):\n        for i, w in enumerate(ws):\n            if w \u003C= c: dp[c] = max(dp[c], dp[c - w] + vs[i])\n    return dp[cap]\n\ndef t3_lcs(a: str, b: str) -> int:\n    m, n = len(a), len(b); prev = [0] * (n + 1)\n    for i in range(1, m + 1):\n        cur = [0] * (n + 1)\n        for j in range(1, n + 1):\n            cur[j] = prev[j - 1] + 1 if a[i - 1] == b[j - 1] else max(prev[j], cur[j - 1])\n        prev = cur\n    return prev[n]\n\ndef t4_lis(nums: List[int]) -> int:\n    tails = []\n    for x in nums:\n        i = bisect.bisect_left(tails, x)\n        if i == len(tails): tails.append(x)\n        else: tails[i] = x\n    return len(tails)\n\ndef t5_interval_palindrome_cuts(s: str) -> int:\n    n = len(s)\n    is_pal = [[False] * n for _ in range(n)]\n    for i in range(n - 1, -1, -1):\n        for j in range(i, n):\n            is_pal[i][j] = s[i] == s[j] and (j - i \u003C 3 or is_pal[i + 1][j - 1])\n    cut = [float('inf')] * n\n    for j in range(n):\n        if is_pal[0][j]: cut[j] = 0\n        else:\n            for i in range(1, j + 1):\n                if is_pal[i][j]: cut[j] = min(cut[j], cut[i - 1] + 1)\n    return int(cut[n - 1])\n\nif __name__ == \"__main__\":\n    print(t1_01_knapsack(10, [2, 3, 5, 7], [3, 4, 6, 10]))\n    print(t3_lcs(\"abcde\", \"aceb\"), t4_lis([10, 9, 2, 5, 3, 7, 101, 18]))\n    print(t5_interval_palindrome_cuts(\"aabcbdadcb\"))\n```\n```\n\n## 子序列 \u002F 区间 \u002F 状压 \u002F 树形\n\n子序列类通常两串用二维 dp[i][j]。区间 DP 按区间长度枚举，适合回文\u002F博弈\u002F合并石子。状态压缩用 bitmask 表示访问过的点集（TSP）。树形 DFS 对每个子节点返回(选\u002F不选)两状态。\n\n| DP 类型 | 状态定义关键词 | 遍历顺序 | 典型题 |\n|--------|--------------|---------|--------|\n| 01 背包 | dp[c]=容量c时最大价值 | 容量倒序 | LC416 分割等和子集 |\n| 完全背包 | dp[c]=凑硬币最少个数 | 容量正序 | LC322 零钱兑换 |\n| LIS\u002FLCS | dp[i]=以i结尾LIS长 | 双重i\u003Cj | LC300\u002FLC1143 |\n| 区间 DP | dp[i][j]=区间[i,j]最优 | len从短到长 | LC132 分割回文II |\n| 状压 DP | dp[mask]=集合mask最优 | mask从小到大 | LC847 访问所有节点最短路径 |\n| 树形 DP | dfs(node)返回(选,不选) | 后序遍历 | LC337 打家劫舍III |\n\n## 最佳实践\n\n写不出转移方程时先暴力搜索+记忆化，画出递归树就能看到重叠子问题的形状，再转自底向上迭代就清晰了。先过样例再空间优化。","彻底掌握动态规划：先给出通用 DP 解题五步法，再精解五大高频模板：背包类、子序列类、区间DP、状态压缩DP、树形DP，每个模板附典型代码与变形要点。",{"id":6,"username":185,"nickname":185,"avatar":20,"cover_image":20,"bio":20,"website":20,"github":20,"avatar_source":20,"resolved_avatar_url":20,"title":20,"created_at":186},"Choyeon","2026-09-30T18:09:53.330367Z",{"id":24,"name":28,"slug":29,"description":33,"icon":35,"color":36,"cover_image":20,"created_at":37,"post_count":87},[189,194,200,206],{"id":6,"name":190,"slug":191,"color":192,"icon":20,"is_active":141,"created_at":193,"post_count":87},"Python","python","#3776ab","2026-09-30T18:09:53.663835Z",{"id":195,"name":196,"slug":197,"color":198,"icon":20,"is_active":141,"created_at":199,"post_count":87},13,"算法","algorithms","#ef4444","2026-09-30T18:09:53.700921Z",{"id":201,"name":202,"slug":203,"color":204,"icon":20,"is_active":141,"created_at":205,"post_count":87},21,"Rust","rust","#dea584","2026-09-30T18:09:53.723993Z",{"id":178,"name":207,"slug":208,"color":209,"icon":20,"is_active":141,"created_at":210,"post_count":87},"Go","go","#00add8","2026-09-30T18:09:53.726775Z","published","public",149,"算法,Python,Rust,Go","2026-09-15T22:09:53.733462Z","2026-10-01T10:32:42.611877Z"]