diff --git a/.github/workflows/content-check.yml b/.github/workflows/content-check.yml index 317e33a3..e3f7720a 100644 --- a/.github/workflows/content-check.yml +++ b/.github/workflows/content-check.yml @@ -76,3 +76,10 @@ jobs: - name: Lint image references (non-blocking) run: pnpm lint:images || echo "[warn] image lint found issues (non-blocking)" + + # Block PR if newly added/modified MDX is missing a proper description. + # Old files are grandfathered via lib/seo-description.ts (Layer 1 fallback); + # this check only fires on changed files in the PR (uses GITHUB_BASE_REF diff). + # leetcode/ and _translated.md are exempt — see scripts/check-frontmatter-description.mjs + - name: Check MDX frontmatter description + run: pnpm check:frontmatter diff --git a/.gitignore b/.gitignore index 2376dfa5..7957d619 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ AGENTS.md .npmrc /.env.* + +# scripts/generate-descriptions.mjs 的 dry-run / apply 报表(产物,不进 git) +scripts/.descriptions-report.json diff --git a/.husky/pre-commit b/.husky/pre-commit index 9e6e5ef9..ed68b7cc 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -11,5 +11,11 @@ pnpm test || exit 1 pnpm check:pnpm-version || true pnpm check:lockfile || true -# 5) 其余按 lint-staged 处理(如 Prettier) +# 5) 校验新增/修改的 docs MDX 必须有 description(>= 60 字符) +# Bing 2026-05 报告 118 个页面 description 太短,老内容由 lib/seo-description.ts +# 代码层兜底,但新增/修改必须手写,避免再积累低质量 SEO 内容。 +# leetcode/ 和 _translated 自动豁免,详见 scripts/check-frontmatter-description.mjs +pnpm check:frontmatter || exit 1 + +# 6) 其余按 lint-staged 处理(如 Prettier) pnpm exec lint-staged diff --git a/app/[locale]/docs/[...slug]/page.tsx b/app/[locale]/docs/[...slug]/page.tsx index 7ca6b3de..6b769e27 100644 --- a/app/[locale]/docs/[...slug]/page.tsx +++ b/app/[locale]/docs/[...slug]/page.tsx @@ -1,6 +1,7 @@ import { source } from "@/lib/source"; import { safeJsonLdString } from "@/lib/json-ld"; import { SITE_URL } from "@/lib/site-url"; +import { ensureSeoDescription } from "@/lib/seo-description"; import { DocsPage, DocsBody } from "fumadocs-ui/page"; import { notFound } from "next/navigation"; import type { Metadata } from "next"; @@ -65,12 +66,23 @@ export default async function DocPage({ params }: Param) { ? `${SITE_URL}/${locale}/docs/${slugPath}` : `${SITE_URL}/${locale}/docs`; + // JSON-LD description 同步走兜底:避免结构化数据里出现空字符串,否则 + // Google Rich Results 测试会 warning。与 generateMetadata 里的逻辑一致。 + const sectionPathForJsonLd = + (slug ?? []).length > 1 ? (slug ?? []).slice(0, -1) : []; + const articleDescription = ensureSeoDescription({ + description: page.data.description, + title: page.data.title, + sectionPath: sectionPathForJsonLd, + locale, + }); + // TechArticle: 让 docs 在 Google 搜索结果上更可能展示为技术文章卡片 const articleJsonLd = { "@context": "https://schema.org", "@type": "TechArticle", headline: page.data.title, - description: page.data.description, + description: articleDescription, url: docUrl, inLanguage: locale === "en" ? "en-US" : "zh-CN", publisher: { @@ -190,21 +202,35 @@ export async function generateMetadata({ params }: Param): Promise { "", ); + // SEO description 兜底:page.data.description 可能为 undefined/空/极短 + // (96 个 leetcode 题解完全没 description,67 个空,35 个 < 20 字符)。 + // 用 ensureSeoDescription 拼 title + 面包屑 + 站点 tagline 补到 80+ 字符, + // 让 Bing/Google 拿到完整摘要而不是从正文随便抓一段。 + // sectionPath 取 slug 除末段外的所有段(末段是当前页本身,已在 title 里)。 + const slugArr = slug ?? []; + const sectionPath = slugArr.length > 1 ? slugArr.slice(0, -1) : []; + const safeDescription = ensureSeoDescription({ + description: page.data.description, + title: page.data.title, + sectionPath, + locale, + }); + return { title: page.data.title, - description: page.data.description, + description: safeDescription, alternates: { canonical, languages: langs }, openGraph: { type: "article", title: page.data.title, - description: page.data.description, + description: safeDescription, url: canonical, locale: locale === "en" ? "en_US" : "zh_CN", }, twitter: { card: "summary_large_image", title: page.data.title, - description: page.data.description, + description: safeDescription, }, }; } diff --git a/app/[locale]/docs/page.tsx b/app/[locale]/docs/page.tsx index 0a150ab8..00b708fa 100644 --- a/app/[locale]/docs/page.tsx +++ b/app/[locale]/docs/page.tsx @@ -5,6 +5,7 @@ import { hasLocale } from "next-intl"; import { notFound } from "next/navigation"; import { SectionIndex } from "@/app/components/docs/SectionIndex"; import { routing } from "@/i18n/routing"; +import { ensureSeoDescription } from "@/lib/seo-description"; /** * /[locale]/docs 根路由的 landing。Header 的 "文档 / Docs" 链接指到 /docs, @@ -49,11 +50,17 @@ export async function generateMetadata({ params }: Props): Promise { if (!hasLocale(routing.locales, locale)) notFound(); setRequestLocale(locale); + // 走统一兜底:原文本只 ~60 字符,被 Bing 判定为太短。ensureSeoDescription + // 会自动补足到 80+ 字符,并保持中英分别的 tagline。 return { title: locale === "en" ? "Docs" : "文档", - description: - locale === "en" - ? "Involution Hell community knowledge base — AI, CS, jobs, community shares." - : "Involution Hell 社区知识库 — AI、计算机基础、求职、群友分享等分区总览。", + description: ensureSeoDescription({ + description: + locale === "en" + ? "Involution Hell community knowledge base — AI, CS, jobs, community shares." + : "Involution Hell 社区知识库 — AI、计算机基础、求职、群友分享等分区总览。", + title: locale === "en" ? "Docs" : "文档", + locale, + }), }; } diff --git a/app/[locale]/events/[id]/page.tsx b/app/[locale]/events/[id]/page.tsx index 83c9a403..9d095d74 100644 --- a/app/[locale]/events/[id]/page.tsx +++ b/app/[locale]/events/[id]/page.tsx @@ -6,6 +6,7 @@ import { Footer } from "@/app/components/Footer"; import type { EventDetailResponse, EventView } from "../types"; import { InterestButton } from "./InterestButton"; import { sanitizeExternalUrl, sanitizeMediaUrl } from "@/lib/url-safety"; +import { ensureSeoDescription } from "@/lib/seo-description"; /** * /events/[id] 详情页。SSR 拉 /api/events/{id}。 @@ -57,10 +58,26 @@ interface Param { export async function generateMetadata({ params }: Param): Promise { const { id } = await params; const data = await fetchDetail(id); - if (!data) return { title: `活动 #${id} · Involution Hell` }; + if (!data) { + // 没拿到 event 也兜底 description(404 前的过渡态) + return { + title: `活动 #${id} · Involution Hell`, + description: ensureSeoDescription({ + title: `活动 #${id}`, + sectionPath: ["events"], + locale: "zh", + }), + }; + } + // event.description 由用户/管理员录入,长度不可控;走兜底防短。 return { title: `${data.event.title} · Involution Hell`, - description: data.event.description || "Involution Hell 社群活动详情。", + description: ensureSeoDescription({ + description: data.event.description, + title: data.event.title, + sectionPath: ["events"], + locale: "zh", + }), }; } diff --git a/app/[locale]/feed/page.tsx b/app/[locale]/feed/page.tsx index 6689a45e..b1a7e432 100644 --- a/app/[locale]/feed/page.tsx +++ b/app/[locale]/feed/page.tsx @@ -19,12 +19,20 @@ import { FeedAuthWrapper } from "@/app/[locale]/feed/components/FeedAuthWrapper" import type { SharedLinkView, CategorySlug } from "@/app/[locale]/feed/types"; import type { ApiResponse } from "@/app/[locale]/feed/types"; import Link from "next/link"; +import { ensureSeoDescription } from "@/lib/seo-description"; export const revalidate = 120; +// 原 description 只有 24 字符(远低于 Bing 推荐的 150-160),统一走 ensureSeoDescription +// 兜底到 80+ 字符。社区分享墙是公开 SEO 页,搜索摘要质量直接影响 CTR。 export const metadata: Metadata = { title: "社区分享墙 · Involution Hell", - description: "群友精选好文,随手转发,沉淀有价值的信息流。", + description: ensureSeoDescription({ + description: "群友精选好文,随手转发,沉淀有价值的信息流。", + title: "社区分享墙", + sectionPath: ["feed"], + locale: "zh", + }), }; /** diff --git a/content/docs/career/events/coffee-chat.en.md b/content/docs/career/events/coffee-chat.en.md index fece6ee3..4f7fe9c9 100644 --- a/content/docs/career/events/coffee-chat.en.md +++ b/content/docs/career/events/coffee-chat.en.md @@ -1,6 +1,6 @@ --- title: Senior Tech-Industry Engineer Coffee Chat Recap -description: "" +description: "Senior backend engineer shares Australian programmer job search strategies, big company career planning, and platform resources for early-career tech professionals." date: "2025-11-01" tags: - career diff --git a/content/docs/career/events/coffee-chat.md b/content/docs/career/events/coffee-chat.md index f3e44588..ae2e592a 100644 --- a/content/docs/career/events/coffee-chat.md +++ b/content/docs/career/events/coffee-chat.md @@ -1,6 +1,6 @@ --- title: 资深科技大厂程序员Coffee Chat回顾 -description: "" +description: "资深科技大厂程序员Coffee Chat回顾:澳洲程序员求职与职业规划分享会,聚焦大公司作为职业跳板的核心策略与SRE入门路径,详解K8s自动化项目优先于安全背景的实战建议。适合CS/AI求职者、海外程序员及准备回国发展的技术从业者阅读。" date: "2025-11-01" tags: - career diff --git a/content/docs/career/events/event-takeway.en.md b/content/docs/career/events/event-takeway.en.md index bd06d162..591bd2cd 100644 --- a/content/docs/career/events/event-takeway.en.md +++ b/content/docs/career/events/event-takeway.en.md @@ -1,6 +1,6 @@ --- title: Career Events Recap Hub -description: Career Events Recap Introduction Page +description: "Explore career event takeaways on involutionhell.com: interview tips, resume optimization, and role-specific growth insights for job seekers." date: "2025-10-26" tags: - intro diff --git a/content/docs/career/events/event-takeway.md b/content/docs/career/events/event-takeway.md index bd503715..d4174d82 100644 --- a/content/docs/career/events/event-takeway.md +++ b/content/docs/career/events/event-takeway.md @@ -1,6 +1,6 @@ --- title: 求职活动回放站 -description: Career Events Recap Introduction Page +description: "求职活动回放站系统整理社区往期活动精华,涵盖Coffee Chat问答、面试实录与技巧总结、岗位经验分享等核心内容。适合正在求职或准备转行的CS/AI学生与职场新人,通过真实案例拆解与成长路径参考,帮助高效复用社区沉淀的面试与职业发展干货。" date: "2025-10-26" tags: - intro diff --git a/content/docs/career/index.en.mdx b/content/docs/career/index.en.mdx new file mode 100644 index 00000000..9bf8d695 --- /dev/null +++ b/content/docs/career/index.en.mdx @@ -0,0 +1,19 @@ +--- +title: Career +description: "Involution Hell tech docs — Career section. A one-stop resource hub for the entire CS/AI job search journey: LeetCode grinding strategies, behavioral interview (BQ) and online assessment (OA) tips, plus highlights from community events like Coffee Chat and Mock Interview." +date: "2026-04-18" +docId: crr0001index2026041800000001 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +import { SectionIndex } from "@/app/components/docs/SectionIndex"; + +One-stop content for the job search journey: + +- **Interview Prep**: LeetCode grinding, BQ, OA, and Video Interview techniques +- **Events**: Recaps of community events — Coffee Chat, Mock Interview, Career Journey, and more + + diff --git a/content/docs/career/index.mdx b/content/docs/career/index.mdx index b5b13f06..6a0e1397 100644 --- a/content/docs/career/index.mdx +++ b/content/docs/career/index.mdx @@ -1,6 +1,6 @@ --- title: Career -description: 求职准备、面试经验、社群活动——从刷题到拿 offer 的全流程。 +description: "内卷地狱技术文档站 Career 页面汇总求职全流程资源:涵盖 LeetCode 刷题策略、BQ 行为面试与 OA 在线评估技巧,以及 Coffee Chat、Mock Interview 等社群活动精华。适合正在准备 CS/AI 岗位面试、寻求系统化求职攻略的在校生与转行者。" date: "2026-04-18" docId: crr0001index2026041800000001 --- diff --git a/content/docs/career/interview-prep/bq.en.md b/content/docs/career/interview-prep/bq.en.md index 625ab3d1..01104c9c 100644 --- a/content/docs/career/interview-prep/bq.en.md +++ b/content/docs/career/interview-prep/bq.en.md @@ -1,6 +1,6 @@ --- title: Behavioral Interview -description: First page +description: "Master behavioral interviews with 10 universal angles—prepare one story per angle for collaboration, conflict, and client service. For CS/AI job seekers." date: "2025-09-11" tags: - intro diff --git a/content/docs/career/interview-prep/bq.md b/content/docs/career/interview-prep/bq.md index ad7931da..9fd3e55b 100644 --- a/content/docs/career/interview-prep/bq.md +++ b/content/docs/career/interview-prep/bq.md @@ -1,6 +1,6 @@ --- title: 行为面 -description: First page +description: "行为面十题万能思路覆盖合作沟通、领导组织、学习成长与挑战应对四大类,详解Teamwork、Conflict、Leadership、Planning、Multitasking、Learn new skills、Motivation、Challenge、Failure等关键技术点,适合求职面试者、CS/AI从业者及准备行为面(BQ)的候选人阅读。" date: "2025-09-11" tags: - intro diff --git a/content/docs/career/interview-prep/interview-tips.en.mdx b/content/docs/career/interview-prep/interview-tips.en.mdx index 8d579a4b..f2c9f4d1 100644 --- a/content/docs/career/interview-prep/interview-tips.en.mdx +++ b/content/docs/career/interview-prep/interview-tips.en.mdx @@ -1,6 +1,6 @@ --- title: "Conquering Every Interview Stage | OA Coding Grind, HireVue Score Tricks, and Group Interview Tactics" -description: "" +description: "Master OA coding, HireVue scoring, and group interviews with proven tactics for international students and job seekers facing tough tech interview stages." date: "2025-09-19" tags: - interview-preparation diff --git a/content/docs/career/interview-prep/interview-tips.mdx b/content/docs/career/interview-prep/interview-tips.mdx index 4447d8c1..6fab2347 100644 --- a/content/docs/career/interview-prep/interview-tips.mdx +++ b/content/docs/career/interview-prep/interview-tips.mdx @@ -1,6 +1,6 @@ --- title: "面试阶段逐关击破 | OA刷题血泪史 + VI分数偷看技巧 + 群面套路合集" -description: "" +description: "澳洲IT求职面试全流程攻略:OA刷题血泪史(HackerRank/CodeSignal/SHL平台拆解)、VI视频面评分偷看技巧、群面套路合集。适合在澳留学生、CS/AI求职者、想提升面试通过率的新手。" date: "2025-09-19" tags: - interview-preparation diff --git a/content/docs/career/interview-prep/leetcode/1004-max-consecutive-ones-iii.en.md b/content/docs/career/interview-prep/leetcode/1004-max-consecutive-ones-iii.en.md index 36aa5c0d..d9ffae77 100644 --- a/content/docs/career/interview-prep/leetcode/1004-max-consecutive-ones-iii.en.md +++ b/content/docs/career/interview-prep/leetcode/1004-max-consecutive-ones-iii.en.md @@ -1,5 +1,6 @@ --- title: "1004. Max Consecutive Ones III" +description: "LeetCode 1004. Max Consecutive Ones III — sliding window with at most k zeros flipped, using two pointers to track the longest subarray; for intermediate learners." date: "2022.12.07-01:15" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/1004_translated.md b/content/docs/career/interview-prep/leetcode/1004_translated.md index 8f0c41bd..7263adf5 100644 --- a/content/docs/career/interview-prep/leetcode/1004_translated.md +++ b/content/docs/career/interview-prep/leetcode/1004_translated.md @@ -1,5 +1,6 @@ --- title: 1004.Maximum continuity1Number III Maximum continuity1Number III +description: "LeetCode 1004. 最大连续1的个数 III 题解 — 滑动窗口与双指针解法,核心技巧在于维护窗口内最多翻转 K 个 0,通过动态调整左右指针实现最长连续 1 子数组。适合准备算法面试、刷题进阶的 CS 求职者与 AI 学习者。" date: "2022.12.07-01:15" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/121-best-time-to-buy-and-sell-stock.en.md b/content/docs/career/interview-prep/leetcode/121-best-time-to-buy-and-sell-stock.en.md index 761ac0f7..132cf569 100644 --- a/content/docs/career/interview-prep/leetcode/121-best-time-to-buy-and-sell-stock.en.md +++ b/content/docs/career/interview-prep/leetcode/121-best-time-to-buy-and-sell-stock.en.md @@ -1,5 +1,6 @@ --- title: "121. Best Time to Buy and Sell Stock" +description: "LeetCode 121. Best Time to Buy and Sell Stock — DP approach tracking min price and max profit in one pass, O(n) time and O(1) space, for coding interview prep." date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/1234-replace-substring-for-balanced-string.en.md b/content/docs/career/interview-prep/leetcode/1234-replace-substring-for-balanced-string.en.md index fe320cb7..f87a9135 100644 --- a/content/docs/career/interview-prep/leetcode/1234-replace-substring-for-balanced-string.en.md +++ b/content/docs/career/interview-prep/leetcode/1234-replace-substring-for-balanced-string.en.md @@ -1,5 +1,6 @@ --- title: "1234. Replace the Substring for Balanced String — Daily Problem" +description: 'LeetCode 1234. Replace the Substring for Balanced String — two-pointer sliding window approach to find minimal substring where outside characters exceed n/4, using frequency counting and the "at most m" trick for O(n) solution. For intermediate algorithm learners.' date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/1234. \346\233\277\346\215\242\345\255\220\344\270\262\345\276\227\345\210\260\345\271\263\350\241\241\345\255\227\347\254\246\344\270\262_translated.md" "b/content/docs/career/interview-prep/leetcode/1234. \346\233\277\346\215\242\345\255\220\344\270\262\345\276\227\345\210\260\345\271\263\350\241\241\345\255\227\347\254\246\344\270\262_translated.md" index 092711ea..a0e90be7 100644 --- "a/content/docs/career/interview-prep/leetcode/1234. \346\233\277\346\215\242\345\255\220\344\270\262\345\276\227\345\210\260\345\271\263\350\241\241\345\255\227\347\254\246\344\270\262_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/1234. \346\233\277\346\215\242\345\255\220\344\270\262\345\276\227\345\210\260\345\271\263\350\241\241\345\255\227\347\254\246\344\270\262_translated.md" @@ -1,5 +1,6 @@ --- title: 1234. Replace the sub -string to get a balanced string One question daily +description: "LeetCode 1234. 替换子串得到平衡字符串 题解 — 使用同向双指针(滑动窗口)维护待替换子串,核心技巧是检查窗口外各字符出现次数是否均不超过 n/4,从而找到最小替换长度。适合备战面试、刷滑动窗口与字符串平衡类题目的算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/1333-filter-restaurants-by-vegan-friendly-price-and-distance.en.md b/content/docs/career/interview-prep/leetcode/1333-filter-restaurants-by-vegan-friendly-price-and-distance.en.md index 07aba716..4937be76 100644 --- a/content/docs/career/interview-prep/leetcode/1333-filter-restaurants-by-vegan-friendly-price-and-distance.en.md +++ b/content/docs/career/interview-prep/leetcode/1333-filter-restaurants-by-vegan-friendly-price-and-distance.en.md @@ -1,5 +1,6 @@ --- title: "1333. Filter Restaurants by Vegan-Friendly, Price, and Distance" +description: "LeetCode 1333. Filter Restaurants by Vegan-Friendly, Price, and Distance — Sort and filter restaurants using list comprehension with lambda for multi-key sorting by rating then ID, for Python developers." date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/142-linked-list-cycle-ii.en.md b/content/docs/career/interview-prep/leetcode/142-linked-list-cycle-ii.en.md index fc98fb23..7dd3af8f 100644 --- a/content/docs/career/interview-prep/leetcode/142-linked-list-cycle-ii.en.md +++ b/content/docs/career/interview-prep/leetcode/142-linked-list-cycle-ii.en.md @@ -1,5 +1,6 @@ --- title: "142. Linked List Cycle II" +description: "LeetCode 142. Linked List Cycle II — Two-pointer technique to detect cycle entrance using Floyd’s algorithm; find first meeting point, then reset one pointer to head and move both one step until they meet. For developers preparing for coding interviews." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/142.\347\216\257\345\275\242\351\223\276\350\241\250II_translated.md" "b/content/docs/career/interview-prep/leetcode/142.\347\216\257\345\275\242\351\223\276\350\241\250II_translated.md" index 690952e6..5f42da65 100644 --- "a/content/docs/career/interview-prep/leetcode/142.\347\216\257\345\275\242\351\223\276\350\241\250II_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/142.\347\216\257\345\275\242\351\223\276\350\241\250II_translated.md" @@ -1,5 +1,6 @@ --- title: 142.Ring linkedII.md +description: "LeetCode 142. 环形链表 II 题解 — 使用快慢双指针检测链表环入口,核心技巧是相遇后重置慢指针到头节点、同步步进直至再次相遇。适合准备算法面试、刷链表题型的 CS 求职者与 LeetCode 学习者阅读。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/146-lru-cache.en.md b/content/docs/career/interview-prep/leetcode/146-lru-cache.en.md index 8656c431..61fd893e 100644 --- a/content/docs/career/interview-prep/leetcode/146-lru-cache.en.md +++ b/content/docs/career/interview-prep/leetcode/146-lru-cache.en.md @@ -1,5 +1,6 @@ --- title: "146. LRU Cache" +description: "LeetCode 146. LRU Cache — Simulates LRU with a dictionary for O(1) get/put; no linked list needed. For developers learning caching strategies." date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/1545-find-kth-bit-in-nth-binary-string.en.md b/content/docs/career/interview-prep/leetcode/1545-find-kth-bit-in-nth-binary-string.en.md index 1110de1b..55ebb2fb 100644 --- a/content/docs/career/interview-prep/leetcode/1545-find-kth-bit-in-nth-binary-string.en.md +++ b/content/docs/career/interview-prep/leetcode/1545-find-kth-bit-in-nth-binary-string.en.md @@ -1,5 +1,6 @@ --- title: "1545. Find Kth Bit in Nth Binary String" +description: "LeetCode 1545. Find Kth Bit in Nth Binary String — recursive approach using string length rules and bit inversion to locate the kth bit without building the full string, for intermediate algorithm learners." date: "2026.03.04 00:46" tags: - Leetcode diff --git a/content/docs/career/interview-prep/leetcode/1653-minimum-deletions-to-make-string-balanced.en.md b/content/docs/career/interview-prep/leetcode/1653-minimum-deletions-to-make-string-balanced.en.md index 8989e7c4..e40b0259 100644 --- a/content/docs/career/interview-prep/leetcode/1653-minimum-deletions-to-make-string-balanced.en.md +++ b/content/docs/career/interview-prep/leetcode/1653-minimum-deletions-to-make-string-balanced.en.md @@ -1,5 +1,6 @@ --- title: "1653. Minimum Deletions to Make String Balanced" +description: "LeetCode 1653. Minimum Deletions to Make String Balanced — DP and stack-free counting with two passes, tracking 'a' and 'b' counts to minimize deletions for CS learners." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/1653. \344\275\277\345\255\227\347\254\246\344\270\262\345\271\263\350\241\241\347\232\204\346\234\200\345\260\221\345\210\240\351\231\244\346\254\241\346\225\260_translated.md" "b/content/docs/career/interview-prep/leetcode/1653. \344\275\277\345\255\227\347\254\246\344\270\262\345\271\263\350\241\241\347\232\204\346\234\200\345\260\221\345\210\240\351\231\244\346\254\241\346\225\260_translated.md" index d560c026..96799c27 100644 --- "a/content/docs/career/interview-prep/leetcode/1653. \344\275\277\345\255\227\347\254\246\344\270\262\345\271\263\350\241\241\347\232\204\346\234\200\345\260\221\345\210\240\351\231\244\346\254\241\346\225\260_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/1653. \344\275\277\345\255\227\347\254\246\344\270\262\345\271\263\350\241\241\347\232\204\346\234\200\345\260\221\345\210\240\351\231\244\346\254\241\346\225\260_translated.md" @@ -1,5 +1,6 @@ --- title: 1653. The minimum number of times to balance the string balance.md +description: "LeetCode 1653. 使字符串平衡的最少删除次数题解 — 通过动态规划与状态机思想,将字符映射为数值((c - 'a') * 2 - 1)消除分支预测失败,提升执行效率。详解如何用一次遍历与最小前缀/后缀计数,计算删除最少字符使字符串中所有 a 在 b 之后。适合备战面试、追求高性能解法的 LeetCode 刷题者与算法竞赛选手。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/1664-ways-to-make-a-fair-array.en.md b/content/docs/career/interview-prep/leetcode/1664-ways-to-make-a-fair-array.en.md index f9f6d942..008a3d10 100644 --- a/content/docs/career/interview-prep/leetcode/1664-ways-to-make-a-fair-array.en.md +++ b/content/docs/career/interview-prep/leetcode/1664-ways-to-make-a-fair-array.en.md @@ -1,5 +1,6 @@ --- title: "1664. Ways to Make a Fair Array — Daily Problem" +description: "LeetCode 1664. Ways to Make a Fair Array — Use prefix/suffix sums to track even/odd index parity shifts after deletion, for O(n) solution. Ideal for intermediate coders learning DP optimization." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/1664\347\224\237\346\210\220\345\271\263\350\241\241\346\225\260\347\273\204\347\232\204\346\226\271\346\241\210\346\225\260_translated.md" "b/content/docs/career/interview-prep/leetcode/1664\347\224\237\346\210\220\345\271\263\350\241\241\346\225\260\347\273\204\347\232\204\346\226\271\346\241\210\346\225\260_translated.md" index f16e3bef..c40ea629 100644 --- "a/content/docs/career/interview-prep/leetcode/1664\347\224\237\346\210\220\345\271\263\350\241\241\346\225\260\347\273\204\347\232\204\346\226\271\346\241\210\346\225\260_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/1664\347\224\237\346\210\220\345\271\263\350\241\241\346\225\260\347\273\204\347\232\204\346\226\271\346\241\210\346\225\260_translated.md" @@ -1,5 +1,6 @@ --- title: 1664. Number of schemes to generate balance numbers One question daily +description: "LeetCode 1664. 生成平衡数组的方案数 题解 — 使用动态规划与奇偶性分析,核心技巧是预处理前缀奇偶和与后缀奇偶和,在枚举删除每个元素时 O(1) 判断剩余数组奇偶下标和是否相等。适合准备算法面试、刷 LeetCode 中等题的求职者和 CS 学生。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/1825-mk-average.en.md b/content/docs/career/interview-prep/leetcode/1825-mk-average.en.md index 3bc789e1..e19f5bbe 100644 --- a/content/docs/career/interview-prep/leetcode/1825-mk-average.en.md +++ b/content/docs/career/interview-prep/leetcode/1825-mk-average.en.md @@ -1,5 +1,6 @@ --- title: "1825. Find MK Average" +description: "LeetCode 1825. Find MK Average — Maintain three multisets for smallest k, middle, and largest k elements; track middle sum for O(1) average queries. Ideal for engineers mastering data structure design." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/1825\346\261\202\345\207\272 MK \345\271\263\345\235\207\345\200\274_translated.md" "b/content/docs/career/interview-prep/leetcode/1825\346\261\202\345\207\272 MK \345\271\263\345\235\207\345\200\274_translated.md" index 41847552..758ccacc 100644 --- "a/content/docs/career/interview-prep/leetcode/1825\346\261\202\345\207\272 MK \345\271\263\345\235\207\345\200\274_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/1825\346\261\202\345\207\272 MK \345\271\263\345\235\207\345\200\274_translated.md" @@ -1,5 +1,6 @@ --- title: 1825. Seek out MK average value +description: "LeetCode 1825. 求出 MK 平均值 题解 — 使用三个 multiset 维护滑动窗口中的最小值、中间值和最大值集合,通过平衡插入与删除操作保持 lower 和 upper 各含 k 个元素,并实时维护 middle 的元素和以 O(log n) 计算剔除首尾 k 个后的平均值。适合准备系统设计面试或需要掌握有序集合与滑动窗口技巧的算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/1828-queries-on-number-of-points-inside-a-circle.en.md b/content/docs/career/interview-prep/leetcode/1828-queries-on-number-of-points-inside-a-circle.en.md index 495d175a..74cb7bcd 100644 --- a/content/docs/career/interview-prep/leetcode/1828-queries-on-number-of-points-inside-a-circle.en.md +++ b/content/docs/career/interview-prep/leetcode/1828-queries-on-number-of-points-inside-a-circle.en.md @@ -1,5 +1,6 @@ --- title: "1828. Queries on Number of Points Inside a Circle — Daily Problem" +description: "LeetCode 1828. Queries on Number of Points Inside a Circle — O(n²) Euclidean distance solution for counting points inside each circle, ideal for beginners learning geometry in coding problems." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/1828\347\273\237\350\256\241\344\270\200\344\270\252\345\234\206\344\270\255\347\202\271\347\232\204\346\225\260\347\233\256_translated.md" "b/content/docs/career/interview-prep/leetcode/1828\347\273\237\350\256\241\344\270\200\344\270\252\345\234\206\344\270\255\347\202\271\347\232\204\346\225\260\347\233\256_translated.md" index 692d2af8..fa090655 100644 --- "a/content/docs/career/interview-prep/leetcode/1828\347\273\237\350\256\241\344\270\200\344\270\252\345\234\206\344\270\255\347\202\271\347\232\204\346\225\260\347\233\256_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/1828\347\273\237\350\256\241\344\270\200\344\270\252\345\234\206\344\270\255\347\202\271\347\232\204\346\225\260\347\233\256_translated.md" @@ -1,5 +1,6 @@ --- title: 1828. Statistics the number of a circle mid -point One question daily +description: "LeetCode 1828. 统计一个圆中点的数目 题解 — 使用欧几里得距离公式计算每个点与圆心的距离,判断是否小于等于半径,时间复杂度 O(n^2)。关键技巧是直接遍历所有点与所有圆,无需优化。适合正在刷 LeetCode 每日一题、入门数学类模拟题的求职者和算法初学者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/213-house-robber-ii.en.md b/content/docs/career/interview-prep/leetcode/213-house-robber-ii.en.md index 0175cc3b..595b38b9 100644 --- a/content/docs/career/interview-prep/leetcode/213-house-robber-ii.en.md +++ b/content/docs/career/interview-prep/leetcode/213-house-robber-ii.en.md @@ -1,5 +1,6 @@ --- title: "213. House Robber II" +description: "LeetCode 213. House Robber II — Dynamic programming with circular array handling; split into two linear DP runs (skip first or last house) to break the cycle. For intermediate learners." date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/2131-longest-palindrome-by-concatenating-two-letter-words.en.md b/content/docs/career/interview-prep/leetcode/2131-longest-palindrome-by-concatenating-two-letter-words.en.md index 101c93e0..ad35cab0 100644 --- a/content/docs/career/interview-prep/leetcode/2131-longest-palindrome-by-concatenating-two-letter-words.en.md +++ b/content/docs/career/interview-prep/leetcode/2131-longest-palindrome-by-concatenating-two-letter-words.en.md @@ -1,5 +1,6 @@ --- title: "2131. Longest Palindrome by Concatenating Two Letter Words" +description: "LeetCode 2131. Longest Palindrome by Concatenating Two Letter Words — hash map approach to pair words with their reverses, plus a center check for palindromic words; for intermediate algorithm learners." date: "2025/5/25-2:33" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.en.md" "b/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.en.md" new file mode 100644 index 00000000..381ec97a --- /dev/null +++ "b/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.en.md" @@ -0,0 +1,97 @@ +--- +title: "2131. Longest Palindrome by Concatenating Two Letter Words" +description: "LeetCode 2131. Longest Palindrome by Concatenating Two Letter Words — solution using a hash map to count word occurrences, pairing words with their reverses to form palindrome pairs, and checking for any self-palindrome word that can serve as the center. Great for interview prep on hash tables and palindrome problems." +date: "2025/5/25-2:33" +tags: + - - Python + - - Answer +abbrlink: 9fa195e5 +docId: ksw2vic4alf1tdnnueay81g8 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# QUESTION + +[2131. Longest Palindrome by Concatenating Two Letter Words](https://leetcode.cn/problems/longest-palindrome-by-concatenating-two-letter-words/description/?envType=daily-question&envId=2025-05-25) + +# My Think + +The idea comes from the brilliant Ling-nc. + +We build a hash map to count the occurrences of each word. + +For each word, we check whether its reverse exists in the hash map. +If it does, they can form a palindrome pair — we update the result and decrease the corresponding count. +If the reverse does not exist, we increment the count for the current word. +Finally, we check if there's any palindromic word that can be used as the center of the palindrome. + +Example: + +1. Input: ["lc", "cl", "gg", "gg"] + +2. "lc" has no pair → stored in the map: { "lc": 1 } + +3. "cl" finds "lc" exists → use "lc" + "cl" as a pair → res += 4 → map updated to { "lc": 0 } + +4. "gg" has no pair → stored in the map: { "lc": 0, "gg": 1 } + +5. Second "gg" finds "gg" exists → use "gg" + "gg" as a pair → res += 4 → map becomes { "lc": 0, "gg": 0 } + + Then we check whether the hash map contains any palindromic word (i.e., a word with two identical characters) that can be used as the center of the final palindrome string. + If such a word exists, we can add 2 more to the result. + +6. Finding a center word (can only pick one symmetric word) + ⚠️ In this example, all "gg" words have been paired, so none is left → no center word is added. + +# Code + +```python +from collections import defaultdict +from typing import List +class Solution: + def longestPalindrome(self, words: List[str]) -> int: + count = defaultdict(int) + res = 0 + for word in words: + if count[word[::-1]] > 0: + count[word[::-1]] -= 1 + res += 4 + else: + count[word] += 1 + for key, value in count.items(): + if key[0] == key[1] and value > 0: + res += 2 + break + return res +``` + +```typescript +function longestPalindrome(words: string[]): number { + const count: Map = new Map(); + let res = 0; + + for (const word of words) { + const reversed = word.split("").reverse().join(""); + const reversedCount = count.get(reversed) ?? 0; + + if (reversedCount > 0) { + count.set(reversed, reversedCount - 1); + res += 2 * word.length; + } else { + count.set(word, (count.get(word) ?? 0) + 1); + } + } + + for (const [word, freq] of count.entries()) { + if (word === word.split("").reverse().join("") && freq > 0) { + res += word.length; + break; // 只能选一个居中的回文串 + } + } + + return res; +} +``` diff --git "a/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md" "b/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md" index c924c727..6e9953aa 100644 --- "a/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md" +++ "b/content/docs/career/interview-prep/leetcode/2131. \350\277\236\346\216\245\344\270\244\345\255\227\346\257\215\345\215\225\350\257\215\345\276\227\345\210\260\347\232\204\346\234\200\351\225\277\345\233\236\346\226\207\344\270\262.md" @@ -1,5 +1,6 @@ --- title: 2131. 连接两字母单词得到的最长回文串.md +description: "LeetCode 2131. 连接两字母单词得到的最长回文串题解 — 使用哈希表统计单词出现次数,通过检查当前单词的反向是否存在来配对回文对,最后判断是否有自回文单词作为中心。适合准备算法面试、刷 LeetCode 哈希表与回文串题型的同学阅读。" date: "2025/5/25-2:33" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/219-contains-duplicate-ii.en.md b/content/docs/career/interview-prep/leetcode/219-contains-duplicate-ii.en.md index b2fb1e38..f133acf8 100644 --- a/content/docs/career/interview-prep/leetcode/219-contains-duplicate-ii.en.md +++ b/content/docs/career/interview-prep/leetcode/219-contains-duplicate-ii.en.md @@ -1,5 +1,6 @@ --- title: "219. Contains Duplicate II — Hash Table Approach" +description: "LeetCode 219. Contains Duplicate II — Sliding window and hash set approach to check if any duplicate exists within k distance, for coding interview prep." date: "2024.01.01 0:00" categories: - - Python diff --git a/content/docs/career/interview-prep/leetcode/219_translated.md b/content/docs/career/interview-prep/leetcode/219_translated.md index a3931689..7e0e2f31 100644 --- a/content/docs/career/interview-prep/leetcode/219_translated.md +++ b/content/docs/career/interview-prep/leetcode/219_translated.md @@ -1,5 +1,6 @@ --- title: 219.Existing duplicate elements II Hash table graphics +description: "LeetCode 219. 存在重复元素 II 题解 — 使用哈希表与滑动窗口双指针解法,核心技巧是维护一个长度不超过 k+1 的窗口,在窗口内快速检测重复元素。适合正在刷 LeetCode 数组与哈希表题目的求职者或算法学习者。" date: "2024.01.01 0:00" categories: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.en.md b/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.en.md new file mode 100644 index 00000000..588fa61d --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.en.md @@ -0,0 +1,97 @@ +--- +title: "2241. Design an ATM Machine" +description: "LeetCode 2241. Design an ATM Machine — solution using a greedy algorithm to simulate ATM deposit and withdrawal logic. The core technique is iterating denominations in reverse (500→20) with a hash map tracking banknote counts, always using the largest denomination first. Suitable for CS/AI job seekers preparing for system design interviews or practicing medium-difficulty simulation problems." +date: "2025-01-06" +tags: + - - Python + - - Answer +abbrlink: a21411f +docId: lzrh7ftq3kegsyx8gimonrfu +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem + +[2241. Design an ATM Machine](https://leetcode.cn/problems/design-an-atm-machine/description/?envType=daily-question&envId=2025-01-05) + +There is an ATM machine that stores banknotes of 5 denominations: $20, $50, $100, $200, and $500. Initially the ATM is empty. Users can deposit or withdraw money. + +When withdrawing, the machine prioritizes using banknotes of larger denominations. + +For example, if you want to withdraw $300 and there are 2 $50 banknotes, 1 $100 banknote, and 1 $200 banknote, the machine will use the $100 and $200 banknotes. + +However, if you try to withdraw $600 and there are 3 $200 banknotes and 1 $500 banknote, the request will be rejected — the machine first tries to use the $500 banknote, then cannot make up the remaining $100. Note that switching to $200 banknotes instead of the $500 is not allowed. + +Implement the ATM class: + +- `ATM()` initializes the ATM object. +- `void deposit(int[] banknotesCount)` deposits new banknotes in the order $20, $50, $100, $200, $500. +- `int[] withdraw(int amount)` returns an array of length 5 representing the number of banknotes of each denomination handed to the user (in the order $20, $50, $100, $200, $500), and updates the ATM's remaining banknotes. Returns `[-1]` if the withdrawal is impossible (no banknotes are dispensed in that case). + +# Approach + +The goal of this problem is to simulate an ATM — dispense exactly as much as requested, no more and no less. I use a greedy strategy, because the statement "if there are 3 `$200` banknotes and 1 `$500` banknote, the withdrawal request will be rejected" tells us we can skip the knapsack problem entirely and apply simple greedy logic. + +Since there are only five denominations — `20`, `50`, `100`, `200`, `500` — we store them in a list and iterate as needed. We then create a `defaultdict()` to maintain a hash map of banknote counts for each denomination. + +`deposit()` builds a reverse-order dictionary. Since we need to traverse from the largest to the smallest denomination, a reverse dictionary is very convenient here. + +Assuming the initial `amount` is `600`, the first denomination encountered is `500`, which fits the problem's logic perfectly. + +In the `withdraw()` function, I create a deep copy of the dictionary as a temporary store. This way, when we need to return `[-1]`, the original banknote counts remain unchanged — avoiding the need for backtracking. + +Sylvia and I used two different traversal approaches: she iterated over the denomination list, while I iterated directly over the dictionary (effectively over its keys). + +1. If the current amount (`600`) is greater than or equal to the current denomination (`500`), try to deduct. If all banknotes of that denomination are used up, move to the next denomination. +2. If not fully used up, deduct as much as possible from `amount` and continue to the next denomination. +3. If `amount` still has a remainder at the end, return `[-1]`; otherwise, calculate the total number of banknotes consumed — that is the answer. + +# Code + +```python +import copy +from typing import List + +from collections import defaultdict + + +class ATM: + + def __init__(self): + self.sd = defaultdict(int) + self.amount = ['20', '50', '100', '200', '500'] + + def deposit(self, banknotesCount: List[int]) -> None: + for i in range(len(banknotesCount) - 1, -1, -1): + self.sd[self.amount[i]] += banknotesCount[i] + + + + def withdraw(self, amount: int) -> List[int]: + tempSd = copy.deepcopy(self.sd) + # key = 面值, value = 张数 + for key, value in tempSd.items(): + if amount >= int(key) and value > 0: + # 需要多少张钞票 + howManyPiece = amount // int(key) + if howManyPiece >= value: + # 全部取出来 + tempSd[key] = 0 + amount -= value * int(key) + else: + # 取出这么多钞票 + tempSd[key] -= howManyPiece + amount -= int(key) * howManyPiece + else: + if amount > 0: + return [-1] + else: + ans = [] + for i in self.sd.keys(): + ans.append(self.sd[i] - tempSd[i]) + self.sd = copy.deepcopy(tempSd) + return ans[::-1] +``` diff --git a/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.zh.md b/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.zh.md index afe77cd4..87ea28a1 100644 --- a/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.zh.md +++ b/content/docs/career/interview-prep/leetcode/2241-design-an-atm-machine.zh.md @@ -1,5 +1,6 @@ --- title: "2241. 设计 ATM 机器" +description: "LeetCode 2241. 设计 ATM 机器 题解 — 使用贪心算法模拟 ATM 取款与存款逻辑,核心技巧是反向遍历面额数组(500→20)并利用哈希表或数组记录各面额钞票数量,优先使用大面额钞票。适合准备系统设计面试或刷 LeetCode 中等模拟题的 CS/AI 求职者。" date: "2025-01-06" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.en.md b/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.en.md new file mode 100644 index 00000000..e708ca74 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.en.md @@ -0,0 +1,101 @@ +--- +title: "2241. Design an ATM Machine" +description: "LeetCode 2241. Design an ATM Machine — simulating bank ATM deposit and withdrawal logic with a focus on implementing a greedy withdrawal strategy: always use the largest denomination first (500, 200, 100, 50, 20), and handle cases where the balance is insufficient or cannot be evenly dispensed. Suitable for algorithm learners preparing for system design interviews or practicing object-oriented simulation problems." +date: "2025-01-06" +tags: + - - Python + - - Answer +abbrlink: a21411f +docId: lzrh7ftq3kegsyx8gimonrfu +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# QUESTION + +[2241. Design an ATM Machine](https://leetcode.cn/problems/design-an-atm-machine/description/?envType=daily-question&envId=2025-01-05) + +There is an ATM machine that stores banknotes of 5 denominations: 20, 50, 100, 200, and 500 dollars. Initially the ATM is empty. The user can use the machine to deposit or withdraw any amount of money. + +When withdrawing, the machine prioritizes using banknotes of larger values. + +For example, if you want to withdraw $300 and there are 2 $50 banknotes, 1 $100 banknote, and 1 $200 banknote, then the machine will use the $100 and $200 banknotes. +However, if you try to withdraw $600 and there are 3 $200 banknotes and 1 $500 banknote, then the withdraw request will be rejected because the machine will first try to use the $500 banknote and then be unable to use banknotes to complete the remaining $100. Note that the machine is not allowed to use the $200 banknotes instead of the $500 banknote. + +Implement the ATM class: + +ATM() Initializes the ATM object. +void deposit(int[] banknotesCount) Deposits new banknotes in the order $20, $50, $100, $200, and $500. +int[] withdraw(int amount) Returns an array of length 5 of the number of banknotes that will be handed to the user in the order $20, $50, $100, $200, and $500, and update the number of banknotes in the ATM after withdrawing. Returns [-1] if it is not possible (do not withdraw any banknotes in this case). + +# My Think + +The purpose of this question is to simulate an ATM machine, which returns the amount of money you withdraw, no more and no less. I am greedy, because the second sentence "There are 3 `$200` bills and 1 `$500` bill in the machine, so the withdrawal request will be rejected" +This shows that we can skip thinking about the knapsack problem in complex dynamic programming and directly consider simple greed. + +Because the denominations of the deposited money are only `20`, `50`, `100`, `200`, `500`, we can store them in the list in advance and wait for traversal. + +Then we create a `defaultdict()` to create a hash table for each denomination in the ATM machine. + +`deposit()` creates a reverse traversal dictionary. Because we need to traverse the dictionary from large denominations to small denominations, the reverse dictionary is very convenient at this time. + +Assuming the initial `amount` is `600`, the first denomination traversed is `500`, It fits the logic of the question very well. + +For the `withdraw()` function, I created a temporary dictionary deep copy storage so that the initial array will not be changed when `[-1]` is returned. Otherwise, it will be troublesome to backtrack. + +Here, Sylvia and I used two different traversal methods. She traversed the list of denominations, while I traversed the dictionary directly (actually traversed the key directly). + +1. If the current denomination (`600`) is greater than the current denomination (`500`), then try to deduct it. If the bank money is withdrawn directly, then look at the next denomination. + +2. If it is not withdrawn, then `amount` deducts the deductible share and then continues to look at the next denomination. + +3. If there is still `amount` left at the end, return `[-1]`, otherwise calculate how many bills have been consumed in total, which is the answer. + +# Code + +```python +import copy +from typing import List + +from collections import defaultdict + + +class ATM: + + def __init__(self): + self.sd = defaultdict(int) + self.amount = ['20', '50', '100', '200', '500'] + + def deposit(self, banknotesCount: List[int]) -> None: + for i in range(len(banknotesCount) - 1, -1, -1): + self.sd[self.amount[i]] += banknotesCount[i] + + + + def withdraw(self, amount: int) -> List[int]: + tempSd = copy.deepcopy(self.sd) + # key = 面值, value = 张数 + for key, value in tempSd.items(): + if amount >= int(key) and value > 0: + # 需要多少张钞票 + howManyPiece = amount // int(key) + if howManyPiece >= value: + # 全部取出来 + tempSd[key] = 0 + amount -= value * int(key) + else: + # 取出这么多钞票 + tempSd[key] -= howManyPiece + amount -= int(key) * howManyPiece + else: + if amount > 0: + return [-1] + else: + ans = [] + for i in self.sd.keys(): + ans.append(self.sd[i] - tempSd[i]) + self.sd = copy.deepcopy(tempSd) + return ans[::-1] +``` diff --git a/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.md b/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.md index 107aa260..d296e39a 100644 --- a/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.md +++ b/content/docs/career/interview-prep/leetcode/2241. Design an ATM Machine.md @@ -1,5 +1,6 @@ --- title: 2241. Design an ATM Machine.md +description: "LeetCode 2241. Design an ATM Machine 题解 — 模拟银行 ATM 的存款与取款逻辑,重点实现贪心取款策略:优先使用大面额钞票(500、200、100、50、20),并处理余额不足或无法凑整时的拒绝场景。适合准备系统设计面试或练习面向对象模拟题的算法学习者。" date: "2025-01-06" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.en.md b/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.en.md new file mode 100644 index 00000000..bce47bc5 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.en.md @@ -0,0 +1,45 @@ +--- +title: "2270. Number of Ways to Split Array" +description: "LeetCode 2270. Number of Ways to Split Array — solution using prefix sums and a single traversal to count valid split points. The core technique is maintaining left and right subarray sums and comparing whether the left side is greater than or equal to the right. Suitable for job seekers and beginners practicing array interval sum problems." +date: "2025/1/14-9:31" +tags: + - - Python + - - Answer +abbrlink: c25bb550 +docId: a6inw303oslb7i5tcqj5xxx4 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem + +[2270. Number of Ways to Split Array](https://leetcode.cn/problems/number-of-ways-to-split-array/description/) + +# Approach + +`2 <= nums.length <= 10^5`, so we can directly take the first element. The initial state has the pointer at index 0, about to move to index 1. A single `for` loop is all we need. + +The second method is the key one — taken from the editorial. + +# Code + +```python +class Solution: + def waysToSplitArray(self, nums: List[int]) -> int: + temp_sum = nums[0] + total_sum = sum(nums) - temp_sum + ans = 0 + for i in range(1, len(nums)): + if temp_sum >= total_sum: + ans += 1 + temp_sum += nums[i] + total_sum -= nums[i] + return ans +``` + +```python +t = (sum(nums) + 1) // 2 +return sum(s >= t for s in accumulate(nums[:-1])) +``` diff --git a/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.zh.md b/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.zh.md index a758f657..7befc446 100644 --- a/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.zh.md +++ b/content/docs/career/interview-prep/leetcode/2270-number-of-ways-to-split-array.zh.md @@ -1,5 +1,6 @@ --- title: "2270. 分割数组的方案数" +description: "LeetCode 2270. 分割数组的方案数 题解 — 使用前缀和与一次遍历统计合法分割点,核心技巧是维护左右两段和并比较左段是否大于等于右段,适合准备数组区间和类面试题的求职者与刷题初学者。" date: "2025/1/14-9:31" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.en.md b/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.en.md new file mode 100644 index 00000000..b1b39053 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.en.md @@ -0,0 +1,45 @@ +--- +title: "2270. Number of Ways to Split Array" +description: "LeetCode 2270. Number of Ways to Split Array — solution using prefix sums and a single traversal to compute the total number of valid array splits. The key technique is maintaining left and right subarray sums and comparing them dynamically. Suitable for algorithm learners preparing for interviews and looking to reinforce prefix sum skills." +date: "2025/1/14-9:31" +tags: + - - Python + - - Answer +abbrlink: c25bb550 +docId: a6inw303oslb7i5tcqj5xxx4 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# QUESTION + +[2270. Number of Ways to Split Array](https://leetcode.cn/problems/number-of-ways-to-split-array/description/) + +# My Think + +`2 <= nums.length <= 10^5`, so we can directly take the first element. The initial state has the pointer at index 0, about to move to index 1. A single `for` loop is all we need. + +The second method is the key one — taken from the editorial. + +# Code + +```python +class Solution: + def waysToSplitArray(self, nums: List[int]) -> int: + temp_sum = nums[0] + total_sum = sum(nums) - temp_sum + ans = 0 + for i in range(1, len(nums)): + if temp_sum >= total_sum: + ans += 1 + temp_sum += nums[i] + total_sum -= nums[i] + return ans +``` + +```python +t = (sum(nums) + 1) // 2 +return sum(s >= t for s in accumulate(nums[:-1])) +``` diff --git a/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.md b/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.md index 27318c13..d67502f3 100644 --- a/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.md +++ b/content/docs/career/interview-prep/leetcode/2270. Number of Ways to Split Array.md @@ -1,5 +1,6 @@ --- title: 2270. Number of Ways to Split Array.md +description: "LeetCode 2270. Number of Ways to Split Array 题解 — 使用前缀和与一次遍历计算数组分割方式总数,关键技巧是维护左右子数组和并动态比较,适合准备面试、刷题巩固数组与前缀和技巧的算法学习者。" date: "2025/1/14-9:31" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2293-min-max-game.en.md b/content/docs/career/interview-prep/leetcode/2293-min-max-game.en.md index 0b237c1d..625fa06b 100644 --- a/content/docs/career/interview-prep/leetcode/2293-min-max-game.en.md +++ b/content/docs/career/interview-prep/leetcode/2293-min-max-game.en.md @@ -1,5 +1,6 @@ --- title: "2293. Min Max Game — Daily Problem" +description: "LeetCode 2293. Min Max Game — Recursively reduce an array by pairing elements and alternating min/max comparisons, using a 2D list to avoid index confusion. For intermediate developers." date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2293_translated.md b/content/docs/career/interview-prep/leetcode/2293_translated.md index 8d07611f..7a3b05f0 100644 --- a/content/docs/career/interview-prep/leetcode/2293_translated.md +++ b/content/docs/career/interview-prep/leetcode/2293_translated.md @@ -1,5 +1,6 @@ --- title: One question daily 2293. Great mini game +description: "LeetCode 2293. 极大极小游戏 题解 — 通过递归思想将一维数组不断转化为二维数组操作,避免索引变化混乱;利用 flag 计数交替取最大值与最小值,适合正在刷简单题、巩固递归与数组处理技巧的算法初学者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2299-strong-password-checker-ii.en.md b/content/docs/career/interview-prep/leetcode/2299-strong-password-checker-ii.en.md index b6716565..b4907eed 100644 --- a/content/docs/career/interview-prep/leetcode/2299-strong-password-checker-ii.en.md +++ b/content/docs/career/interview-prep/leetcode/2299-strong-password-checker-ii.en.md @@ -1,5 +1,6 @@ --- title: "2299. Strong Password Checker II — Daily Problem" +description: "LeetCode 2299. Strong Password Checker II — Simulate password validation with bitmask tracking lowercase, uppercase, digit, and special characters; O(n) time, for LeetCode solvers." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2299\345\274\272\345\257\206\347\240\201\346\243\200\351\252\214\345\231\250II_translated.md" "b/content/docs/career/interview-prep/leetcode/2299\345\274\272\345\257\206\347\240\201\346\243\200\351\252\214\345\231\250II_translated.md" index a016137a..2b99fb1f 100644 --- "a/content/docs/career/interview-prep/leetcode/2299\345\274\272\345\257\206\347\240\201\346\243\200\351\252\214\345\231\250II_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/2299\345\274\272\345\257\206\347\240\201\346\243\200\351\252\214\345\231\250II_translated.md" @@ -1,5 +1,6 @@ --- title: One question daily 2299. Code inspection device II +description: "LeetCode 2299. 强密码检验器 II 题解 — 模拟与位运算检查密码强度,使用掩码 mask 记录是否包含小写字母、大写字母、数字和特殊字符,并确保无连续相同字符。适合刷题求职者、准备算法面试的 CS 学生。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2309-greatest-english-letter-in-upper-and-lower-case.en.md b/content/docs/career/interview-prep/leetcode/2309-greatest-english-letter-in-upper-and-lower-case.en.md index 4e2a8686..2aa098c3 100644 --- a/content/docs/career/interview-prep/leetcode/2309-greatest-english-letter-in-upper-and-lower-case.en.md +++ b/content/docs/career/interview-prep/leetcode/2309-greatest-english-letter-in-upper-and-lower-case.en.md @@ -1,5 +1,6 @@ --- title: "2309. Greatest English Letter in Upper and Lower Case — Daily Problem" +description: "LeetCode 2309. Greatest English Letter in Upper and Lower Case — Hash table or bit manipulation to find the highest letter appearing in both cases; for developers preparing for coding interviews." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2309\345\205\274\345\205\267\345\244\247\345\260\217\345\206\231\347\232\204\346\234\200\345\245\275\350\213\261\346\226\207\345\255\227\346\257\215_translated.md" "b/content/docs/career/interview-prep/leetcode/2309\345\205\274\345\205\267\345\244\247\345\260\217\345\206\231\347\232\204\346\234\200\345\245\275\350\213\261\346\226\207\345\255\227\346\257\215_translated.md" index baecb6ad..0017e4d3 100644 --- "a/content/docs/career/interview-prep/leetcode/2309\345\205\274\345\205\267\345\244\247\345\260\217\345\206\231\347\232\204\346\234\200\345\245\275\350\213\261\346\226\207\345\255\227\346\257\215_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/2309\345\205\274\345\205\267\345\244\247\345\260\217\345\206\231\347\232\204\346\234\200\345\245\275\350\213\261\346\226\207\345\255\227\346\257\215_translated.md" @@ -2,6 +2,7 @@ title: >- 2309. The best English letters with both appropriates and lowercases One question daily +description: "LeetCode 2309. 兼具大小写的最好英文字母 题解 — 使用哈希表与位运算两种解法,哈希表法从 Z 开始逆序查找字母是否同时出现大小写,位运算法用两个整数掩码分别记录小写和大写字母出现情况,再通过与运算找出最高位对应字母。适合正在刷 LeetCode 每日一题、想掌握哈希表与位运算技巧的求职者和算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2335-minimum-amount-of-time-to-fill-cups.en.md b/content/docs/career/interview-prep/leetcode/2335-minimum-amount-of-time-to-fill-cups.en.md index f8ab9355..61be3c17 100644 --- a/content/docs/career/interview-prep/leetcode/2335-minimum-amount-of-time-to-fill-cups.en.md +++ b/content/docs/career/interview-prep/leetcode/2335-minimum-amount-of-time-to-fill-cups.en.md @@ -1,5 +1,6 @@ --- title: "2335. Minimum Amount of Time to Fill Cups — Daily Problem" +description: "LeetCode 2335. Minimum Amount of Time to Fill Cups — Greedy approach: always serve the two largest counts first, using sorting or a max-heap; alternatively, a mathematical formula handles edge cases efficiently for developers preparing for interviews." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277_translated.md" "b/content/docs/career/interview-prep/leetcode/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277_translated.md" index 4027129e..c5f5818f 100644 --- "a/content/docs/career/interview-prep/leetcode/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277_translated.md" @@ -1,5 +1,6 @@ --- title: 2335. The shortest total time to be filled with a cup One question daily +description: "LeetCode 2335. 装满杯子需要的最短总时长 题解 — 贪心策略与数学分类讨论两种解法,核心技巧是每次选取剩余最多的两种饮料进行配对,或利用 x+y≤z 直接得出答案。适合正在刷每日一题、学习贪心算法与数学优化的求职者和算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2341-maximum-number-of-pairs-in-array.en.md b/content/docs/career/interview-prep/leetcode/2341-maximum-number-of-pairs-in-array.en.md index a5857a01..fd25757f 100644 --- a/content/docs/career/interview-prep/leetcode/2341-maximum-number-of-pairs-in-array.en.md +++ b/content/docs/career/interview-prep/leetcode/2341-maximum-number-of-pairs-in-array.en.md @@ -1,5 +1,6 @@ --- title: "2341. Maximum Number of Pairs in Array — Daily Problem" +description: "LeetCode 2341. Maximum Number of Pairs in Array — Hash table or sorting approach to count pairs and leftovers, for developers practicing array frequency problems." tags: - - Python - - answer diff --git "a/content/docs/career/interview-prep/leetcode/2341. \346\225\260\347\273\204\350\203\275\345\275\242\346\210\220\345\244\232\345\260\221\346\225\260\345\257\271_translated.md" "b/content/docs/career/interview-prep/leetcode/2341. \346\225\260\347\273\204\350\203\275\345\275\242\346\210\220\345\244\232\345\260\221\346\225\260\345\257\271_translated.md" index 49015330..bf9640f7 100644 --- "a/content/docs/career/interview-prep/leetcode/2341. \346\225\260\347\273\204\350\203\275\345\275\242\346\210\220\345\244\232\345\260\221\346\225\260\345\257\271_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/2341. \346\225\260\347\273\204\350\203\275\345\275\242\346\210\220\345\244\232\345\260\221\346\225\260\345\257\271_translated.md" @@ -1,5 +1,6 @@ --- title: 2341. How much can the array be formed One question daily +description: "LeetCode 2341. 数组能形成多少数对 题解 — 使用哈希表(Counter)统计每个数字出现次数,通过整除2计算可形成数对数量,关键技巧是排序后双指针或直接哈希计数。适合正在刷LeetCode每日一题、学习哈希表与计数算法的求职者和CS/AI学习者。" tags: - - Python - - answer diff --git a/content/docs/career/interview-prep/leetcode/2490-circular-sentence.en.md b/content/docs/career/interview-prep/leetcode/2490-circular-sentence.en.md index 94bd8b38..3d360211 100644 --- a/content/docs/career/interview-prep/leetcode/2490-circular-sentence.en.md +++ b/content/docs/career/interview-prep/leetcode/2490-circular-sentence.en.md @@ -1,5 +1,6 @@ --- title: "2490. Circular Sentence" +description: "LeetCode 2490. Circular Sentence — Check if a sentence is circular by splitting into words and verifying each word's last character matches the next word's first character, wrapping around. For beginners." date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2562-find-the-array-concatenation-value.en.md b/content/docs/career/interview-prep/leetcode/2562-find-the-array-concatenation-value.en.md index c111d273..f20539bb 100644 --- a/content/docs/career/interview-prep/leetcode/2562-find-the-array-concatenation-value.en.md +++ b/content/docs/career/interview-prep/leetcode/2562-find-the-array-concatenation-value.en.md @@ -1,5 +1,6 @@ --- title: "2562. Find the Array Concatenation Value" +description: "LeetCode 2562. Find the Array Concatenation Value — two-pointer approach to concatenate first and last numbers as strings and sum them, for intermediate Python learners." date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/2582-pass-the-pillow.en.md b/content/docs/career/interview-prep/leetcode/2582-pass-the-pillow.en.md index 14aed75b..591ee0fc 100644 --- a/content/docs/career/interview-prep/leetcode/2582-pass-the-pillow.en.md +++ b/content/docs/career/interview-prep/leetcode/2582-pass-the-pillow.en.md @@ -1,5 +1,6 @@ --- title: "2582. Pass the Pillow" +description: "LeetCode 2582. Pass the Pillow — Math pattern solution using period (n-1) and full cycles to determine forward/backward position, ideal for coding interview prep." date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/2639-find-column-width-of-grid.en.md b/content/docs/career/interview-prep/leetcode/2639-find-column-width-of-grid.en.md index 1e8a5716..361b0727 100644 --- a/content/docs/career/interview-prep/leetcode/2639-find-column-width-of-grid.en.md +++ b/content/docs/career/interview-prep/leetcode/2639-find-column-width-of-grid.en.md @@ -1,5 +1,6 @@ --- title: "2639. Find the Width of Columns of a Grid" +description: "LeetCode 2639. Find the Width of Columns of a Grid — compute max digit length per column in O(n²) using string conversion and column-wise iteration, ideal for grid traversal practice." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2639. \346\237\245\350\257\242\347\275\221\346\240\274\345\233\276\344\270\255\346\257\217\344\270\200\345\210\227\347\232\204\345\256\275\345\272\246_translated.md" "b/content/docs/career/interview-prep/leetcode/2639. \346\237\245\350\257\242\347\275\221\346\240\274\345\233\276\344\270\255\346\257\217\344\270\200\345\210\227\347\232\204\345\256\275\345\272\246_translated.md" index 6c3937e3..3540805c 100644 --- "a/content/docs/career/interview-prep/leetcode/2639. \346\237\245\350\257\242\347\275\221\346\240\274\345\233\276\344\270\255\346\257\217\344\270\200\345\210\227\347\232\204\345\256\275\345\272\246_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/2639. \346\237\245\350\257\242\347\275\221\346\240\274\345\233\276\344\270\255\346\257\217\344\270\200\345\210\227\347\232\204\345\256\275\345\272\246_translated.md" @@ -1,5 +1,6 @@ --- title: 2639. Query the width of each column in the grid diagram.md +description: "LeetCode 2639. 查询网格图中每一列的宽度 题解 — 使用 NumPy 库高效计算每列数字字符串最大宽度,关键技巧包括矩阵转置与列迭代。适合正在刷 LeetCode 数组与矩阵题型、希望掌握 NumPy 加速列运算的 Python 求职者与算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2679-sum-in-a-matrix.en.md b/content/docs/career/interview-prep/leetcode/2679-sum-in-a-matrix.en.md index 97d6fe11..80039bf5 100644 --- a/content/docs/career/interview-prep/leetcode/2679-sum-in-a-matrix.en.md +++ b/content/docs/career/interview-prep/leetcode/2679-sum-in-a-matrix.en.md @@ -1,5 +1,6 @@ --- title: "2679. Sum in a Matrix" +description: "LeetCode 2679. Sum in a Matrix — Sort each row, then use zip and max to find the column-wise maximums and sum them. For Python developers learning matrix traversal tricks." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2679.\347\237\251\351\230\265\344\270\255\347\232\204\345\222\214_translated.md" "b/content/docs/career/interview-prep/leetcode/2679.\347\237\251\351\230\265\344\270\255\347\232\204\345\222\214_translated.md" index 3329bacc..f023cd3e 100644 --- "a/content/docs/career/interview-prep/leetcode/2679.\347\237\251\351\230\265\344\270\255\347\232\204\345\222\214_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/2679.\347\237\251\351\230\265\344\270\255\347\232\204\345\222\214_translated.md" @@ -1,5 +1,6 @@ --- title: 2679.In the matrix and the harmony.md +description: "LeetCode 2679. 矩阵中的和 题解 — 先对每行子数组排序,再用 zip 一次性纵向遍历所有行,每列取最大值后求和。关键技巧:排序预处理 + zip 解包实现列级最大值提取。适合正在刷排序与矩阵操作题的 Python 求职者与算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/2894-divisible-and-non-divisible-sums-difference.en.md b/content/docs/career/interview-prep/leetcode/2894-divisible-and-non-divisible-sums-difference.en.md index b5cc348e..1cc47c8e 100644 --- a/content/docs/career/interview-prep/leetcode/2894-divisible-and-non-divisible-sums-difference.en.md +++ b/content/docs/career/interview-prep/leetcode/2894-divisible-and-non-divisible-sums-difference.en.md @@ -1,5 +1,6 @@ --- title: "2894. Divisible and Non-divisible Sums Difference" +description: "LeetCode 2894. Divisible and Non-divisible Sums Difference — O(1) math solution using arithmetic series formulas to compute the difference without loops, ideal for beginners learning number theory." date: "2025.05.27 23:52" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.en.md" "b/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.en.md" new file mode 100644 index 00000000..e581e85f --- /dev/null +++ "b/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.en.md" @@ -0,0 +1,53 @@ +--- +title: "2894. Divisible and Non-Divisible Sums Difference" +description: "LeetCode 2894. Divisible and Non-Divisible Sums Difference — direct mathematical solution using the arithmetic series formula to compute the sum of numbers divisible by m and those that are not in [1, n], then taking their difference. Suitable for job seekers and algorithm beginners working through easy math problems on LeetCode." +date: "2025.05.27 23:52" +tags: + - - Python + - - answer + - - typescript +abbrlink: 66adcc9e +docId: y0ntwlksnvj7ymuapqvkvmwr +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +[2894. Divisible and Non-Divisible Sums Difference](https://leetcode.cn/problems/divisible-and-non-divisible-sums-difference/description/) + +# Thought + +**Problem statement:** +In $[1, n]$, find the difference between the sum of all numbers not divisible by $m$ and the sum of all numbers divisible by $m$. + +**Derivation:** + +1. Total sum: + $S_{\text{total}} = \sum_{i=1}^{n} i = \frac{n(n+1)}{2}$ + +2. Numbers divisible by $m$ are: $m, 2m, 3m, \dots, \left\lfloor \frac{n}{m} \right\rfloor m$ + $S_{\text{divisible}} = m \cdot \left(1 + 2 + \dots + k\right) = m \cdot \frac{k(k+1)}{2}$ + +3. Therefore the sum of non-divisible numbers is: + $S_{\text{not\_div}} = S_{\text{total}} - S_{\text{divisible}}$ + +4. The answer is: + $\text{difference} = S_{\text{not\_div}} - S_{\text{divisible}}$ + $= \frac{n(n+1)}{2} - m \cdot \frac{\left\lfloor \frac{n}{m} \right\rfloor(\left\lfloor \frac{n}{m} \right\rfloor+1)}{2} - m \cdot \frac{\left\lfloor \frac{n}{m} \right\rfloor(\left\lfloor \frac{n}{m} \right\rfloor+1)}{2}$ + $= \frac{n(n+1)}{2} - m \cdot \left\lfloor \frac{n}{m} \right\rfloor(\left\lfloor \frac{n}{m} \right\rfloor+1)$ + +# Code + +```python +class Solution: + def differenceOfSums(self, n: int, m: int) -> int: + # divisible = m * (1 + n // m) * (n // m) // 2 + # undivisible = n * (n + 1) // 2 - n * ((1 + n // m) * (n // m) // 2) + return - m * ((1 + n // m) * (n // m)) + (n * (n + 1) >> 1) +``` + +```typescript +const differenceOfSums = (n: number, m: number): number => + -m * ((1 + Math.floor(n / m)) * Math.floor(n / m)) + ((n * (n + 1)) >> 1); +``` diff --git "a/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.md" "b/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.md" index 1709ff79..17a8addd 100644 --- "a/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.md" +++ "b/content/docs/career/interview-prep/leetcode/2894. \345\210\206\347\261\273\346\261\202\345\222\214\345\271\266\344\275\234\345\267\256.md" @@ -1,5 +1,6 @@ --- title: 2894. 分类求和并作差 +description: "LeetCode 2894. 分类求和并作差题解 — 使用数学公式直接计算,通过等差数列求和公式分别求出能被 m 整除与不能被 m 整除的数的总和,再作差得到结果。适合正在刷 LeetCode 简单数学题的求职者与算法初学者阅读。" date: "2025.05.27 23:52" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/3072-distribute-elements-into-two-arrays-ii.en.md b/content/docs/career/interview-prep/leetcode/3072-distribute-elements-into-two-arrays-ii.en.md index 0769b160..5a33bb48 100644 --- a/content/docs/career/interview-prep/leetcode/3072-distribute-elements-into-two-arrays-ii.en.md +++ b/content/docs/career/interview-prep/leetcode/3072-distribute-elements-into-two-arrays-ii.en.md @@ -1,5 +1,6 @@ --- title: "3072. Distribute Elements into Two Arrays II" +description: "LeetCode 3072. Distribute Elements into Two Arrays II — Use Fenwick tree for O(n log n) counting of greater elements; reverse array and process from left to right, applying tie-breaking rules to distribute into two arrays. For intermediate learners." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/3072. \345\260\206\345\205\203\347\264\240\345\210\206\351\205\215\345\210\260\344\270\244\344\270\252\346\225\260\347\273\204\344\270\255 II_translated.md" "b/content/docs/career/interview-prep/leetcode/3072. \345\260\206\345\205\203\347\264\240\345\210\206\351\205\215\345\210\260\344\270\244\344\270\252\346\225\260\347\273\204\344\270\255 II_translated.md" index bb1e83e4..1066e147 100644 --- "a/content/docs/career/interview-prep/leetcode/3072. \345\260\206\345\205\203\347\264\240\345\210\206\351\205\215\345\210\260\344\270\244\344\270\252\346\225\260\347\273\204\344\270\255 II_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/3072. \345\260\206\345\205\203\347\264\240\345\210\206\351\205\215\345\210\260\344\270\244\344\270\252\346\225\260\347\273\204\344\270\255 II_translated.md" @@ -1,5 +1,6 @@ --- title: 3072. Allocate elements into two arrays II.md +description: "LeetCode 3072. 将元素分配到两个数组中 II 题解 — 使用树状数组(Fenwick Tree)维护两个数组中大于当前值的元素计数,通过离散化与二分索引实现 O(n log n) 高效分配。适合备战高频算法面试、需要掌握树状数组与离散化技巧的求职者与竞赛选手。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.en.md b/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.en.md new file mode 100644 index 00000000..6d89e329 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.en.md @@ -0,0 +1,82 @@ +--- +title: "3138. Minimum Length of Anagram Concatenation" +description: "LeetCode 3138. Minimum Length of Anagram Concatenation — solution by enumerating substring lengths and using a hash map to verify whether the string can be formed by concatenating anagrams. The core technique is using character frequency arrays to check whether the substring's repeat multiplier matches the original string. Suitable for job seekers preparing for coding assessments and interviews who want to strengthen skills in string and counting algorithms." +date: 20/12/2024 +tags: + - Python + - Prefix Sum + - Hash Table + - String + - Counting +abbrlink: d1339d55 +docId: o3knuvbpnki6isfjv3g5ohau +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem Description + +https://leetcode.cn/problems/minimum-length-of-anagram-concatenation/description/?envType=daily-question&envId=2024-12-20 + +You are given a string `s`, which is known to be a concatenation of anagrams of some string `t`. + +Return the minimum possible length of the string `t`. + +An anagram is formed by rearranging the letters of a string. For example, "aab", "aba", and "baa" are all anagrams of "aab". + +#### Example 1: + + Input: s = "abba" + + Output: 2 + + Explanation: + + One possible string t is "ba". + +#### Example 2: + + Input: s = "cdef" + + Output: 4 + + Explanation: + + One possible string t is "cdef". Note that t can equal s. + +# Approach + +Since the problem naturally suggests using a counting method (`Counter`), we need to find the minimum substring for each string. For example, for `abba`, the result is `ab`; for `cdef`, it's `cdef`. +We iterate from length `1` (a single character) onwards, slicing the string to get the current substring. + +Initially, we compute the character count for the original string using `Counter`, which gives us a dictionary of character frequencies. +Next, we only need to check if the count of each character in the current substring multiplied by `n/k` equals the count in the original string (i.e., whether repeating the current substring x times equals the original string). + +# Code + +```python +import collections +class Solution: + def minAnagramLength(self, s: str) -> int: + def check(k: int) -> bool: + # 遍历字符串 s,每次取长度为 k 的子串 + # Iterate over the string `s`, taking substrings of length `k` + for i in range(0, n, k): + # 统计每个字符出现的次数 + # Count the occurrences of each character in the current substring + cnt1 = collections.Counter(s[i: i + k]) + for c, v in cnt.items(): + # 如果每个字符出现的次数乘以 n/k != cnt[] return False + # If the count of any character multiplied by (n // k) != the original count, return False + if cnt1[c] * (n // k) != v: + return False + return True + + cnt = collections.Counter(s) + n = len(s) + for i in range(1, n+1): + if n % i == 0 and check(i): + return i +``` diff --git a/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.zh.md b/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.zh.md index e520f691..04758be0 100644 --- a/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.zh.md +++ b/content/docs/career/interview-prep/leetcode/3138-minimum-length-of-anagram-concatenation.zh.md @@ -1,5 +1,6 @@ --- title: "3138. 同位字符串连接的最小长度" +description: "LeetCode 3138. 同位字符串连接的最小长度题解 — 通过枚举子串长度与哈希表计数判断字符串是否由同位串拼接而成,核心技巧是利用字符频次数组验证子串重复倍数是否匹配原串,适合备战笔试面试、需要强化字符串与计数类算法的求职者与刷题者。" date: 20/12/2024 tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.en.md b/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.en.md new file mode 100644 index 00000000..6a039bd2 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.en.md @@ -0,0 +1,82 @@ +--- +title: "3138. Minimum Length of Anagram Concatenation" +description: "LeetCode 3138. Minimum Length of Anagram Concatenation — using character frequency counting and GCD to determine whether a string is formed by concatenating anagrams. The core technique is enumerating possible segment lengths and verifying consistent character counts across segments. Suitable for algorithm job seekers working through string and math problems." +date: 20/12/2024 +tags: + - Python + - Prefix Sum + - Hash Table + - String + - Counting +abbrlink: d1339d55 +docId: o3knuvbpnki6isfjv3g5ohau +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Description + +https://leetcode.cn/problems/minimum-length-of-anagram-concatenation/description/?envType=daily-question&envId=2024-12-20 + +You are given a string `s`, which is known to be a concatenation of anagrams of some string `t`. + +Return the minimum possible length of the string `t`. + +An anagram is formed by rearranging the letters of a string. For example, "aab", "aba", and, "baa" are anagrams of "aab". + +#### Example 1: + + Input: s = "abba" + + Output: 2 + + Explanation: + + One possible string t could be "ba". + +#### Example 2: + + Input: s = "cdef" + + Output: 4 + + Explanation: + + One possible string t could be "cdef", notice that t can be equal to s. + +# Thinking + +Since the problem naturally suggests using a counting method (`Counter`), we need to find the minimum substring for each string. For example, for `abba`, the result is `ab`; for `cdef`, it's `cdef`. +We iterate from length `1` (a single character) onwards, slicing the string to get the current substring. + +Initially, we compute the character count for the original string using `Counter`, which gives us a dictionary of character frequencies. +Next, we only need to check if the count of each character in the current substring multiplied by `n/k` equals the count in the original string (i.e., whether repeating the current substring x times equals the original string). + +# Code + +```python +import collections +class Solution: + def minAnagramLength(self, s: str) -> int: + def check(k: int) -> bool: + # 遍历字符串 s,每次取长度为 k 的子串 + # Iterate over the string `s`, taking substrings of length `k` + for i in range(0, n, k): + # 统计每个字符出现的次数 + # Count the occurrences of each character in the current substring + cnt1 = collections.Counter(s[i: i + k]) + for c, v in cnt.items(): + # 如果每个字符出现的次数乘以 n/k != cnt[] return False + # If the count of any character multiplied by (n // k) != the original count, return False + if cnt1[c] * (n // k) != v: + return False + return True + + cnt = collections.Counter(s) + n = len(s) + for i in range(1, n+1): + if n % i == 0 and check(i): + return i +``` diff --git a/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.md b/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.md index 1ed00fca..1fa411db 100644 --- a/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.md +++ b/content/docs/career/interview-prep/leetcode/3138. Minimum Length of Anagram Concatenation.md @@ -1,5 +1,6 @@ --- title: 3138. Minimum Length of Anagram Concatenation.md +description: "LeetCode 3138. Minimum Length of Anagram Concatenation 题解 — 利用字符频率计数与最大公约数(GCD)判断字符串是否由若干变位词拼接而成,核心技巧是枚举可能的分段长度并验证各段字符计数一致。适合正在刷字符串与数学类题目的算法求职者。" date: 20/12/2024 tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/345-reverse-vowels-of-a-string.en.md b/content/docs/career/interview-prep/leetcode/345-reverse-vowels-of-a-string.en.md index 43e29d39..e40ad237 100644 --- a/content/docs/career/interview-prep/leetcode/345-reverse-vowels-of-a-string.en.md +++ b/content/docs/career/interview-prep/leetcode/345-reverse-vowels-of-a-string.en.md @@ -1,5 +1,6 @@ --- title: "345. Reverse Vowels of a String" +description: "LeetCode 345. Reverse Vowels of a String — Two-pointer approach to swap vowels from both ends, using a hash set for O(1) vowel lookup. For intermediate Python/Java developers." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215_translated.md" "b/content/docs/career/interview-prep/leetcode/345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215_translated.md" index d0717824..995deb6c 100644 --- "a/content/docs/career/interview-prep/leetcode/345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/345. \345\217\215\350\275\254\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\345\205\203\351\237\263\345\255\227\346\257\215_translated.md" @@ -1,5 +1,6 @@ --- title: 345. Voice letter in the reverse string.md +description: "LeetCode 345. 反转字符串中的元音字母 题解 — 使用双指针技巧从字符串两端向中间遍历,分别定位元音字母并交换位置。关键点在于用哈希集合或条件判断快速识别元音字母(a、e、i、o、u 大小写均可)。适合正在刷 LeetCode 基础题、练习双指针与字符串操作的求职者或 CS 学习者阅读。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/42-trapping-rain-water.en.md b/content/docs/career/interview-prep/leetcode/42-trapping-rain-water.en.md index 94d4e4a2..26a0fbc9 100644 --- a/content/docs/career/interview-prep/leetcode/42-trapping-rain-water.en.md +++ b/content/docs/career/interview-prep/leetcode/42-trapping-rain-water.en.md @@ -1,5 +1,6 @@ --- title: "42. Trapping Rain Water" +description: "LeetCode 42. Trapping Rain Water — two-pointer approach using bucket theory, tracking left/right max heights to calculate trapped water per bar; for intermediate algorithm learners." date: "2025/3/27-19:56" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/42.en.md b/content/docs/career/interview-prep/leetcode/42.en.md new file mode 100644 index 00000000..f6855174 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/42.en.md @@ -0,0 +1,118 @@ +--- +title: "42. Trapping Rain Water" +description: "LeetCode 42. Trapping Rain Water — two-pointer approach combined with the bucket theory: maintain left and right maximum heights to calculate trapped water column by column. Key technique: left and right pointers move inward, comparing each bar's height against the corresponding side's maximum to determine the water level. Suitable for CS job seekers grinding LeetCode hot problems and preparing for algorithm interviews." +date: "2025/3/27-19:56" +tags: + - - Python + - - Answer +abbrlink: 60fe0230 +docId: jv8qj3ljyr2uomaehnv0l77k +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# QUESTION + +[42. Trapping Rain Water]() + +# My Think + +This is a problem I've memorized inside out — totally muscle memory. But I revisited it yesterday and tried to actually understand it. I even made a GIF to help myself visualize what's happening. Here's the code: + +Let's use the example: `[0,1,0,2,1,0,1,3,2,1,2,1]` + +The core idea of this problem is basically the "bucket theory": +We treat the two outermost bars as the "Walls of Maria" — and ignore the inner ones for now. +If that's the case, then the max height of water we can hold is `min(leftmax, rightmax)`. +In other words, the shorter wall decides the water level. + +But height alone isn't enough — we also need width to compute the actual amount of water. +So we look at each bar one by one, and calculate how much water we can trap on top of it, then sum it all up. + +We use two pointers: `left` and `right`, and also keep track of the highest wall on the left (`leftmax`) and the highest wall on the right (`rightmax`). + +When our pointer reaches the end of the string (or the two walls meet), that means we've gone through all the characters — that's when we know we have a valid answer. + +Take this specific frame as an example: + +At this point, the max water we can hold is `leftmax = 2`, but the current column has height `1`, so we can trap: + +`2 - 1 = 1` unit of water. + +If we were comparing `leftmax` and `rightmax` directly, we wouldn't know why this particular column can hold water. The only reason it can trap water is because its height is less than or equal to `leftmax`. + +# Code + +```python +class Solution: + def trap(self, height: list[int]) -> int: + ans = leftmost = rightmost = 0 + left, right = 0, len(height) - 1 + while left < right: + leftmost = max(leftmost, height[left]) + rightmost = max(rightmost, height[right]) + if leftmost <= rightmost: + ans += leftmost - height[left] + left += 1 + else: + ans += rightmost - height[right] + right -= 1 + return ans +``` + +```python +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import numpy as np + +# Given height list for illustration +height = [0,1,0,2,1,0,1,3,2,1,2,1] + +# Initialize variables as in the function +left, right = 0, len(height) - 1 +leftmax = rightmax = 0 +ans = 0 + +# For animation, store each frame's water level and pointers +frames = [] + +# Simulate the logic and capture frames +while left < right: + leftmax = max(leftmax, height[left]) + rightmax = max(rightmax, height[right]) + water = [0] * len(height) + if leftmax <= rightmax: + trapped = max(0, leftmax - height[left]) + ans += trapped + water[left] = trapped + frames.append((height.copy(), water.copy(), left, right)) + left += 1 + else: + trapped = max(0, rightmax - height[right]) + ans += trapped + water[right] = trapped + frames.append((height.copy(), water.copy(), left, right)) + right -= 1 + +# Create animation +fig, ax = plt.subplots(figsize=(10, 5)) + +def update(frame): + ax.clear() + heights, water, l_ptr, r_ptr = frame + indices = np.arange(len(heights)) + ax.bar(indices, heights, color='grey', edgecolor='black') + ax.bar(indices, water, bottom=heights, color='blue', edgecolor='blue', alpha=0.6) + ax.axvline(l_ptr, color='green', linestyle='--', label='Left Pointer') + ax.axvline(r_ptr, color='red', linestyle='--', label='Right Pointer') + ax.set_ylim(0, max(height) + 3) + ax.set_title("Trapping Rain Water Animation") + ax.legend() + +ani = animation.FuncAnimation(fig, update, frames=frames, interval=500, repeat=False) + +from IPython.display import HTML +ani.save("trapping_rain_water.gif", writer="pillow", fps=2) # 保存为 GIF +``` diff --git a/content/docs/career/interview-prep/leetcode/42.md b/content/docs/career/interview-prep/leetcode/42.md index e799677a..8e45829f 100644 --- a/content/docs/career/interview-prep/leetcode/42.md +++ b/content/docs/career/interview-prep/leetcode/42.md @@ -1,5 +1,6 @@ --- title: 42.md +description: "LeetCode 42. 接雨水 题解 — 双指针法结合木桶原理,维护左右最高柱子逐格计算可蓄水量。关键技巧:左指针与右指针向中间移动,每次比较当前柱子与对应侧最高值,取短板决定水位高度。适合正在刷 LeetCode 热题、准备算法面试的 CS 求职者。" date: "2025/3/27-19:56" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/46-permutations.en.md b/content/docs/career/interview-prep/leetcode/46-permutations.en.md new file mode 100644 index 00000000..b0e98fc5 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/46-permutations.en.md @@ -0,0 +1,92 @@ +--- +title: "46. Permutations" +description: "LeetCode 46. Permutations — solution using backtracking with element swapping to generate all permutations via recursion and state restoration (backtracking), enabling full permutation output for arrays without duplicate numbers. Suitable for algorithm learners and job seekers preparing for interviews who want to reinforce backtracking and DFS skills." +date: 24/3/2025 +tags: + - Python + - "9021" + - tree +abbrlink: d567a4cd +docId: mxt0ux1zpbzph4nuxz51eyg7 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem Description + +Given an array `nums` of distinct integers, return all the possible permutations. You can return the answer in any order. + +Example 1: + +Input: nums = [1,2,3] +Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] + +Example 2: + +Input: nums = [0,1] +Output: [[0,1],[1,0]] + +Example 3: + +Input: nums = [1] +Output: [[1]] + +# Approach + +This problem is more like a tree problem — it can be understood with the following tree structure: + +```shell +dfs(0): nums = [1,2,3] +| +|-- i=0: swap(0,0) -> [1,2,3] +| | +| |-- dfs(1) +| |-- i=1: swap(1,1) -> [1,2,3] +| | |-- dfs(2): append [1,2,3] +| |-- i=2: swap(1,2) -> [1,3,2] +| |-- dfs(2): append [1,3,2] +| +|-- i=1: swap(0,1) -> [2,1,3] +| | +| |-- dfs(1) +| |-- i=1: swap(1,1) -> [2,1,3] +| | |-- dfs(2): append [2,1,3] +| |-- i=2: swap(1,2) -> [2,3,1] +| |-- dfs(2): append [2,3,1] +| +|-- i=2: swap(0,2) -> [3,2,1] + | + |-- dfs(1) + |-- i=1: swap(1,1) -> [3,2,1] + | |-- dfs(2): append [3,2,1] + |-- i=2: swap(1,2) -> [3,1,2] + |-- dfs(2): append [3,1,2] + +``` + +We swap the current position `index` with each candidate position `i` from `index` to the end. Think of `index` and `i` as left and right pointers: `index` determines which slot we're filling, and `i` tries placing different numbers in that slot. + +Before the recursive call, we swap `nums[i]` and `nums[index]` to try placing a new number at position `index`. When we reach the last position (`index == len(nums) - 1`), we add the current permutation to the result list. After the recursive call returns, we swap back to restore the original state — this is the backtracking step. + +# Code + +```python +class Solution: + def permute(self, nums: List[int]) -> List[List[int]]: + # index + def dfs(index): + # Reach the last element + if index == len(nums) - 1: + res.append(list(nums)) + return + for i in range(index, len(nums)): + nums[i], nums[index] = nums[index], nums[i] + dfs(index + 1) + nums[i], nums[index] = nums[index], nums[i] + + res = [] + dfs(0) + return res +``` diff --git a/content/docs/career/interview-prep/leetcode/46-permutations.zh.md b/content/docs/career/interview-prep/leetcode/46-permutations.zh.md index dc048920..4dbaab68 100644 --- a/content/docs/career/interview-prep/leetcode/46-permutations.zh.md +++ b/content/docs/career/interview-prep/leetcode/46-permutations.zh.md @@ -1,5 +1,6 @@ --- title: "46. 全排列" +description: "LeetCode 46. 全排列 题解 — 使用回溯算法与交换法生成所有排列,通过递归与状态恢复(回溯)实现不含重复数字数组的全排列输出。适合准备面试、刷题巩固回溯与DFS技巧的算法学习者与求职者。" date: 24/3/2025 tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.en.md" "b/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.en.md" new file mode 100644 index 00000000..de91b969 --- /dev/null +++ "b/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.en.md" @@ -0,0 +1,92 @@ +--- +title: "46. Permutations" +description: "LeetCode 46. Permutations — solution using backtracking (DFS) to recursively generate all permutations by swapping array elements for state restoration, avoiding extra space overhead. The key technique is maintaining a swap pointer to fix the current position and recursively processing subsequent positions. Suitable for CS job seekers and algorithm learners preparing for interviews who want to reinforce backtracking skills." +date: 24/3/2025 +tags: + - Python + - "9021" + - tree +abbrlink: d567a4cd +docId: mxt0ux1zpbzph4nuxz51eyg7 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Description + +Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. + +Example 1: + +Input: nums = [1,2,3] +Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] +Example 2: + +Input: nums = [0,1] +Output: [[0,1],[1,0]] +Example 3: + +Input: nums = [1] +Output: [[1]] + +# Thinking + +This question is more like a tree problem. +like the tree below: + +```shell +dfs(0): nums = [1,2,3] +| +|-- i=0: swap(0,0) -> [1,2,3] +| | +| |-- dfs(1) +| |-- i=1: swap(1,1) -> [1,2,3] +| | |-- dfs(2): append [1,2,3] +| |-- i=2: swap(1,2) -> [1,3,2] +| |-- dfs(2): append [1,3,2] +| +|-- i=1: swap(0,1) -> [2,1,3] +| | +| |-- dfs(1) +| |-- i=1: swap(1,1) -> [2,1,3] +| | |-- dfs(2): append [2,1,3] +| |-- i=2: swap(1,2) -> [2,3,1] +| |-- dfs(2): append [2,3,1] +| +|-- i=2: swap(0,2) -> [3,2,1] + | + |-- dfs(1) + |-- i=1: swap(1,1) -> [3,2,1] + | |-- dfs(2): append [3,2,1] + |-- i=2: swap(1,2) -> [3,1,2] + |-- dfs(2): append [3,1,2] + +``` + +We swap the current position index with each possible candidate `i` from `index` to the end. They can be seen as left and right pointers: `index` determines which position we're filling, and `i` tries different numbers to place there. + +Before the recursive call, we swap `nums[i]` and `nums[index]` to try placing a new number at position index. If we reach the last position (`index == len(nums) - 1`), we add the current permutation to the answer list. +After recursion, we swap back to restore the original state (backtracking). + +# Code + +```python +class Solution: + def permute(self, nums: List[int]) -> List[List[int]]: + # index + def dfs(index): + # Reach the last element + if index == len(nums) - 1: + res.append(list(nums)) + return + for i in range(index, len(nums)): + nums[i], nums[index] = nums[index], nums[i] + dfs(index + 1) + nums[i], nums[index] = nums[index], nums[i] + + res = [] + dfs(0) + return res +``` diff --git "a/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.md" "b/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.md" index 51a05e80..94103cd6 100644 --- "a/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.md" +++ "b/content/docs/career/interview-prep/leetcode/46.\345\205\250\346\216\222\345\210\227.md" @@ -1,5 +1,6 @@ --- title: 46.permutations +description: "LeetCode 46. 全排列 题解 — 使用回溯法(DFS)递归生成所有排列,通过交换数组元素实现状态回溯,避免额外空间开销。关键技巧是维护一个交换指针来固定当前位置,再递归处理后续位置。适合准备面试、刷题巩固回溯算法的 CS 求职者和算法学习者。" date: 24/3/2025 tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/538-convert-bst-to-greater-sum-tree.en.md b/content/docs/career/interview-prep/leetcode/538-convert-bst-to-greater-sum-tree.en.md index 59026844..0182da7f 100644 --- a/content/docs/career/interview-prep/leetcode/538-convert-bst-to-greater-sum-tree.en.md +++ b/content/docs/career/interview-prep/leetcode/538-convert-bst-to-greater-sum-tree.en.md @@ -1,5 +1,6 @@ --- title: "538. Convert BST to Greater Sum Tree" +description: "LeetCode 538. Convert BST to Greater Sum Tree — reverse in-order traversal with cumulative sum, updating each node to the sum of all greater values; for developers preparing for tree manipulation and BST problems." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/538.\346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221_translated.md" "b/content/docs/career/interview-prep/leetcode/538.\346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221_translated.md" index f0f87a82..f45451a0 100644 --- "a/content/docs/career/interview-prep/leetcode/538.\346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/538.\346\212\212\344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\350\275\254\346\215\242\344\270\272\347\264\257\345\212\240\346\240\221_translated.md" @@ -1,5 +1,6 @@ --- title: 538.Convert the binary search tree to cumulative tree +description: "LeetCode 538. 把二叉搜索树转换为累加树 题解 — 利用反向中序遍历(右-根-左)累加节点值,将 BST 原地转换为累加树(Greater Sum Tree),关键技巧是维护全局累加变量记录已遍历节点和。适合准备面试、刷二叉树与递归的算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/6323-distribute-money-to-maximum-children.en.md b/content/docs/career/interview-prep/leetcode/6323-distribute-money-to-maximum-children.en.md index edae8fd6..a1446655 100644 --- a/content/docs/career/interview-prep/leetcode/6323-distribute-money-to-maximum-children.en.md +++ b/content/docs/career/interview-prep/leetcode/6323-distribute-money-to-maximum-children.en.md @@ -1,5 +1,6 @@ --- title: "6323. Distribute Money to Maximum Children" +description: "LeetCode 6323. Distribute Money to Maximum Children — Math problem maximizing children receiving $8, handling remainders and avoiding $4 with greedy adjustments for contest-level logic." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/6323. \345\260\206\351\222\261\345\210\206\347\273\231\346\234\200\345\244\232\347\232\204\345\204\277\347\253\245_translated.md" "b/content/docs/career/interview-prep/leetcode/6323. \345\260\206\351\222\261\345\210\206\347\273\231\346\234\200\345\244\232\347\232\204\345\204\277\347\253\245_translated.md" index 79d6aa66..da572604 100644 --- "a/content/docs/career/interview-prep/leetcode/6323. \345\260\206\351\222\261\345\210\206\347\273\231\346\234\200\345\244\232\347\232\204\345\204\277\347\253\245_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/6323. \345\260\206\351\222\261\345\210\206\347\273\231\346\234\200\345\244\232\347\232\204\345\204\277\347\253\245_translated.md" @@ -1,5 +1,6 @@ --- title: 6323. Child that divides money the most.md +description: "LeetCode 6323. 将钱分给最多的儿童 题解 — 数学贪心分类讨论,核心技巧是优先让每个儿童分到 8 美元,再根据剩余钱数和剩余人数处理边界情况:剩余钱数 >0 且剩余人数为 0 时需从已分 8 美元的儿童中扣减;剩余 1 人且剩余钱数为 3 时同样需扣减;其余情况将剩余钱全部分给一人,若该人分到 4 美元则转给另一人 1 美元,答案不变。适合备战周赛、需要掌握数学贪心与边界条件处理的算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/76-minimum-window-substring.en.md b/content/docs/career/interview-prep/leetcode/76-minimum-window-substring.en.md index 2ad9504c..7e25f698 100644 --- a/content/docs/career/interview-prep/leetcode/76-minimum-window-substring.en.md +++ b/content/docs/career/interview-prep/leetcode/76-minimum-window-substring.en.md @@ -1,5 +1,6 @@ --- title: "76. Minimum Window Substring" +description: "LeetCode 76. Minimum Window Substring — Two-pointer sliding window with dictionary-based character count tracking to find the smallest substring containing all target characters; for developers preparing for coding interviews." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/76\346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262_translated.md" "b/content/docs/career/interview-prep/leetcode/76\346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262_translated.md" index 7a733677..ad460929 100644 --- "a/content/docs/career/interview-prep/leetcode/76\346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/76\346\234\200\345\260\217\350\246\206\347\233\226\345\255\220\344\270\262_translated.md" @@ -1,5 +1,6 @@ --- title: 76Minimum cover string.md +description: "LeetCode 76. 最小覆盖子串 题解 — 滑动窗口 + 双指针 + 哈希表计数,通过右指针扩展窗口、左指针收缩窗口,动态维护字符频次字典以判断是否覆盖目标串 t。适合准备面试、刷 LeetCode 的 CS/AI 求职者与算法学习者阅读。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/80-remove-duplicates-from-sorted-array-ii.en.md b/content/docs/career/interview-prep/leetcode/80-remove-duplicates-from-sorted-array-ii.en.md index ed300fdf..7b4b162b 100644 --- a/content/docs/career/interview-prep/leetcode/80-remove-duplicates-from-sorted-array-ii.en.md +++ b/content/docs/career/interview-prep/leetcode/80-remove-duplicates-from-sorted-array-ii.en.md @@ -1,5 +1,6 @@ --- title: "80. Remove Duplicates from Sorted Array II — Python beats 98.40% using collections.Counter!" +description: "LeetCode 80. Remove Duplicates from Sorted Array II — Uses collections.Counter to cap element frequencies at 2, then modifies the array in-place. For Python developers seeking an O(n) time, O(1) space solution." date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/80_translated.md b/content/docs/career/interview-prep/leetcode/80_translated.md index 29959a74..82c978d8 100644 --- a/content/docs/career/interview-prep/leetcode/80_translated.md +++ b/content/docs/career/interview-prep/leetcode/80_translated.md @@ -1,5 +1,6 @@ --- title: Python beat98.40% collectionsofCounter method! +description: "LeetCode 80. 删除有序数组中的重复项 II 题解 — 使用双指针原地修改数组,允许每个元素最多出现两次,关键技巧是维护慢指针控制写入位置与快指针遍历数组,适合准备面试、需要掌握数组去重与双指针技巧的求职者与算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.en.md b/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.en.md new file mode 100644 index 00000000..d27e1884 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.en.md @@ -0,0 +1,264 @@ +--- +title: "9021_TUT_3 Tutorial 25 — Exercise Set" +description: "LeetCode 9021. Tutorial 25 exercise solutions — covering three problem types: string generation, base conversion, and odd/even pattern generation. Involves list comprehensions, generator expressions, dictionary mapping, and exception handling in Python. Suitable for CS beginners, job seekers working through coding problems, and readers looking to advance their Python skills." +date: 2025/3/07 +tags: + - "9021" + - lab +abbrlink: 974decd3 +docId: s0cadbu09dgu54q0zxttkx7z +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Exercise 1 + +### Problem Description + +You are given two integers `m` and `n`, where: + +- `m` represents the number of repeated units (patterns). +- `n` represents the number of elements (underscores) within each unit. + +The goal is to generate a string where: + +- Each unit contains `n` underscores (`_`), separated by `|`. +- Units are concatenated together, separated by `*`. + +### My Solution + +```python +def generate_struct(n): + return '|'.join(n * ['_']) + +def f1(m, n): + return ' * '.join(m * [generate_struct(n)]) +``` + +#### Approach + +I think of each unit as a separate structure. I decompose the problem by first building the smallest unit (underscores joined by `|`), then using `join()` to concatenate all units with `*`. + +#### Helper Function `generate_struct(n)` + +Generates the basic structure: joins `n` underscores with `|`. +For example, if `n = 2`, the result is `"_|_"`. + +### Standard Solution + +```python +def f1(m, n): + return ' * '.join('|'.join('_' for _ in range(n)) for _ in range(m)) +``` + +### Concise Expression + +The inner `join` creates a string of `n` underscores joined by `|` using a generator expression. The outer `join` repeats this process `m` times and concatenates all units with `*`. + +Comparison: my solution emphasizes modularity (splitting into smaller functions), while the standard solution compresses everything into a single list comprehension. + +# Exercise 2 + +### Problem Description + +Generate a pattern based on the digits of a given number `n`: + +- Odd digits are represented by a black square (⬛). +- Even digits are represented by a white square (⬜). + +### My Solution + +```python +def f2(n): + ans = '' + for i in str(n): + if int(i) % 2 == 0: + ans += '⬜' + else: + ans += '⬛' + print(ans) +``` + +#### Approach + +1. Convert the number `n` to a string and iterate digit by digit. +2. Use the modulus operator (`% 2`) to check whether each digit is odd or even. +3. Append a black square for odd digits and a white square for even digits. +4. Print the final string. + +### Standard Solution + +```python +def f2(n): + print(''.join({0: '⬜', 1: '⬛'}[int(d) % 2] for d in str(n))) +``` + +Dr. Martin's solution is more Pythonic: it uses a dictionary and generator expression for brevity, referencing the square symbols directly via Unicode escape sequences. + +# Exercise 3 + +### Problem Description + +Treat a number `n` as a representation in different bases (2 through 10) and convert it to its base-10 value for each valid base. + +For example, `n = 2143`: + +- `2143` in base 5 equals `298` in base 10. +- `2143` in base 6 equals `495` in base 10. +- And so on. + +### My Solution + +```python +def f3(n: int): + for i in range(2, 11): + try: + value = int(str(n), i) + print(f'{n} is {value} in base {i}') + except ValueError: + pass +``` + +#### Approach + +1. Iterate over bases 2 through 10. +2. Use `int(str(n), i)` to interpret `n` as a base-`i` number and convert to base 10. If the digits are invalid for that base, a `ValueError` is raised and the base is skipped. +3. Use `try-except` to handle invalid bases. + +### Standard Solution + +```python +def f3(n): + n_as_string = str(n) + min_base = max(2, max({int(d) for d in n_as_string}) + 1) + for b in range(min_base, 11): + print(f'{n} is {int(n_as_string, b)} in base {b}') +``` + +The standard solution uses a set comprehension to extract the maximum digit, which determines the minimum valid base — skipping invalid bases without needing exception handling. + +# Exercise 4 + +### Problem Description + +Create a function `f4(n, base)` that returns a dictionary `D`: + +- Keys are integers from `0` to `n`. +- Values are tuples representing each key's value in the given `base` (converted from base 10). + +### My Solution + +```python +def convert_to_base(n, base): + if n == 0: + return '0' + digits = [] + while n: + digits.append(str(n % base)) + n //= base + return ''.join(digits[::-1]) + +def f4(n: int, base: int): + D = {} + for i in range(0, n + 1): + D[i] = tuple(map(int, convert_to_base(i, base))) + return D +``` + +#### Approach + +1. Helper function `convert_to_base(n, base)` converts a decimal number to the target base using repeated division. +2. The main function iterates from `0` to `n`, converts each number, and stores the result as a tuple. + +#### On the Pythonicity of `map()` + +`map()` comes from the functional programming paradigm and is now generally replaced by list comprehensions, which are more concise and readable: + +```python +D[i] = tuple([int(digit) for digit in convert_to_base(i, base)]) +``` + +### Standard Solution + +```python +def f4(n, base): + D = {0: (0,)} + for m in range(1, n + 1): + digits = [] + p = m + while p: + digits.append(p % base) + p //= base + D[m] = tuple(reversed(digits)) + return D +``` + +Both solutions are correct. My approach adds modularity via a helper function; the standard solution is more concise by integrating conversion directly into the main function. + +# Exercise 5 + +First, try running this: + +```python +print(0.1 + 0.2) +``` + +The result is not `0.3` but `0.30000000000000004`. Why? + +### Problem Description + +This exercise is designed to expose the limitations of floating-point arithmetic in computers. Computers store floating-point numbers in binary format, which often introduces precision errors. + +### Solution + +```python +def f5(integral_part, fractional_part): + precision = len(str(fractional_part)) + a_float = float(str(integral_part) + '.' + str(fractional_part)) + simple_precision = f'{a_float:.{precision}f}' + extended_simple_precision = simple_precision + '0' * precision + double_precision = f'{a_float:.{precision * 2}f}' + print('With', precision * 2, 'digits after the decimal point, ', end='') + if extended_simple_precision == double_precision: + print(simple_precision, 'prints out with', precision, 'trailing', + precision == 1 and 'zero,' or 'zeroes,', 'namely, as', + extended_simple_precision + ) + else: + print(simple_precision, 'prints out as', double_precision) +``` + +By comparing simple precision (`simple_precision`) and double precision (`double_precision`), we demonstrate that floating-point numbers are not always stored the way we expect. + +# Exercise 6 + +### Problem Description + +Given: + +- A list `L` containing multiple integer sublists all of the same length `n`. +- A list `fields` that is a permutation of `{1, ..., n}`. + +Sort `L` using a multi-key mechanism: first sort by the position specified by `fields[0]`, break ties using `fields[1]`, and so on. + +For example, `fields = [2, 1]` means sort by the second element first, then by the first element when there are ties. + +### My Solution + +```python +def f6(L, fields): + return sorted(L, key=lambda x: [x[i-1] for i in fields]) +``` + +`sorted()` sorts based on the `key`. The lambda function extracts elements from each sublist at positions specified by `fields`. We use `x[i-1]` because `fields` is 1-indexed while Python lists are 0-indexed. + +### Standard Solution + +```python +def f6(L, fields): + return sorted(L, key=lambda x: tuple(x[i - 1] for i in fields)) +``` + +**Why use a tuple?** Tuples are immutable, and Python's built-in sort can compare them efficiently. Both solutions are correct; the standard solution uses a tuple, which is more conventional in Python. diff --git a/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.zh.md b/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.zh.md index e6830d98..da3022d9 100644 --- a/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.zh.md +++ b/content/docs/career/interview-prep/leetcode/9021-tut-3-25t1.zh.md @@ -1,5 +1,6 @@ --- title: "9021_TUT_3 第 25 次课练习题" +description: "LeetCode 9021. 第 25 次课练习题题解 — 涵盖字符串生成、进制转换与奇偶图案生成三大题型,涉及列表推导式、生成器表达式、字典映射及异常处理等 Python 技巧,适合 CS 初学者、求职刷题者及 Python 编程进阶读者阅读。" date: 2025/3/07 tags: - "9021" diff --git a/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.en.md b/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.en.md new file mode 100644 index 00000000..4b47c1b2 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.en.md @@ -0,0 +1,386 @@ +--- +title: "9021_TUT_3_25T1" +description: "LeetCode 9021. Solution — constructs a string by concatenating repeated structural units, using list generation and string join to decompose the unit structure. Suitable for algorithm beginners and coding interview candidates looking to strengthen foundational string manipulation and divide-and-conquer thinking." +date: 2025/3/07 +tags: + - "9021" + - lab +abbrlink: 974decd3 +docId: s0cadbu09dgu54q0zxttkx7z +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Exercise 1 + +### Problem Description + +You are given two integers, `m` and `n`, where: + +- `m` represents the number of repeated units (patterns). +- `n` represents the number of elements (underscores) within each unit. + +The goal is to generate a string where: + +- Each unit contains `n` underscores (\_), separated by `|`. +- These units are then concatenated together, separated by `*`. + +### My Solution + +```python +def generate_struct(n): + return '|'.join(n * ['_']) + +def f1(m, n): + return ' * '.join(m * [generate_struct(n)]) +``` + +#### My Thought Process + +I think of each unit as a separate structure. So, I decompose the problem by breaking down the smallest unit, which is the structure made of underscores joined by `|`. +After constructing each unit, I use `join()` to combine them together using `*`. + +#### Helper Function generate_struct(n) + +This function generates the basic structure. +It creates a list of underscores (`_`) of length n and joins them with `|`. +Example: If `n = 2`, the result will be "`_|_`". + +### Standard Solution + +```python +def f1(m, n): + return ' * '.join('|'.join('_' for _ in range(n)) for _ in range(m)) +``` + +### Concise Expression + +The inner `join` creates a string of `n` underscores joined by `|` using a generator expression `('_' for _ in range(n))`. +The outer `join` repeats this process `m` times and concatenates the units using `*`. + +In summary, my solution focuses on modularity by breaking down the problem into smaller parts (like creating a structural unit), whereas the standard solution compresses everything into one line using list comprehensions. + +# Exercise 2 + +### Problem Description + +The goal is to generate a pattern based on the digits of a given number n. Specifically: + +If a digit is odd, it should be represented by a black square (⬛). +If a digit is even, it should be represented by a white square (⬜). +The program takes a number n as input and prints a string of squares corresponding to the digits of n. + +### My Solution + +```python +def f2(n): + ans = '' + for i in str(n): + if int(i) % 2 == 0: + ans += '⬜' + else: + ans += '⬛' + print(ans) +``` + +#### My Thought Process + +1. Loop through each digit: + Convert the number n to a string to iterate over each digit individually. + +2. Check if the digit is even or odd: + Convert each digit back to an integer and use the modulus operator (% 2) to check if the digit is even or odd. + +3. Append the corresponding square: + - If the digit is even, append a white square (⬜) to the result string. + - If the digit is odd, append a black square (⬛). + +4. Print the final string: + After processing all the digits, print the final string containing black and white squares. + +### Standard Solution + +```python +def f2(n): + print(''.join({0: '⬜', 1: '⬛'}[int(d) % 2] for d in str(n))) +``` + +Dr. Martin's solution is: + +1. More compact and Pythonic. +2. Uses a dictionary and list comprehension for brevity and efficiency. +3. The Unicode characters for the squares are referenced directly using their escape sequences (`⬜` for white, `⬛` for black). + +# Exercise 3 + +### Problem Description + +In this task, the number `n` is treated as a number expressed in different bases (ranging from 2 to 10), and we aim to convert it into its corresponding base 10 value for each of these bases, where the conversion is valid. + +For n = 2143: + +- `2143` in base `5` is equivalent to `298` in base `10`. +- `2143` in base `6` is equivalent to `495` in base `10`. +- And so on. + +The goal is to iterate over different base systems from 2 to 10, treat the input number `n` as if it is expressed in each base, and then convert it to base 10. + +### My Solution + +```python +def f3(n: int): + for i in range(2, 11): + try: + # Treat n as a number in base i and convert it to base 10 + value = int(str(n), i) + print(f'{n} is {value} in base {i}') + except ValueError: + pass +``` + +#### My Thought Process + +1. Iterating over Bases (2 to 10): + - We loop through the base values i ranging from 2 to 10. + +2. Conversion Using `int()`: + - For each base `i`, we treat the number `n` as a number in that base. To do this, we first convert `n` to a string (`str(n)`) and then use `int()` to interpret it as a base `i` number. + - If the digits of `n` are valid for base `i`, this conversion succeeds, and the result is the base 10 equivalent of `n`. + - If the digits of n are not valid for base i (for example, if base 2 is used and n contains digits greater than 1), a ValueError is raised, and we skip the invalid base. + +3. Handling Errors with `try-except`: + - The `try-except` block ensures that invalid bases are skipped, allowing us to handle cases where the digits in `n` are not valid for a particular base. + +### Standard Solution + +```python +def f3(n): + n_as_string = str(n) + min_base = max(2, max({int(d) for d in n_as_string}) + 1) + for b in range(min_base, 11): + print(f'{n} is {int(n_as_string, b)} in base {b}') +``` + +It skips the bases where the digits in n are not valid, and it uses a set comprehension to extract the unique digits from n_as_string. The maximum digit is then used to determine the minimum base to start iterating from. + +# Exercise 4 + +### Problem Description + +The task is to create a function `f4(n, base)` that returns a dictionary D, where: + +Keys are integers from `0` to `n`. +Values are tuples that represent the base `base` representation of each key, converted from base 10. + +### My Solution + +```python +def convert_to_base(n, base): + if n == 0: + return '0' + digits = [] + while n: + digits.append(str(n % base)) + n //= base + return ''.join(digits[::-1]) + +def f4(n: int, base: int): + D = {} + for i in range(0, n + 1): + D[i] = tuple(map(int, convert_to_base(i, base))) + return D +``` + +#### My Thought Process + +1. Helper Function `convert_to_base(n, base)`: + - This function converts a number `n` from base 10 to the specified base. + - We use a while loop to repeatedly take the modulus (`n % base`) and append the remainder to the list `digits`. + - We then divide `n` by `base` `(n //= base)` to reduce it for the next iteration. + - After collecting all digits, we reverse the list and return it as a string. + +2. Main Function `f4(n, base)`: + We initialize an empty dictionary `D`. + For each number `i` from `0` to `n`, we convert `i` to the given base using `convert_to_base()`. + The converted base digits are then mapped to integers and stored in a tuple as the value for each key `i` in the dictionary. + +### Explanation of Why `map()` is not Pythonic + +In the function f4, the use of `map(int, convert_to_base(i, base))` applies the `int` function +to each element of the result from `convert_to_base`, effectively converting each character to an integer. + +However, it's worth noting that the `map()` function, which originates from functional programming, +has largely been superseded by more Pythonic constructs such as list comprehensions. + +These comprehensions are generally considered superior for several reasons: + +- They are more elegant and concise. +- They tend to be shorter in terms of syntax, making the code easier to read. +- They are easier to understand for most people, especially those who are more familiar with Python's + standard syntax rather than functional programming constructs. +- In many cases, they are also more efficient in terms of performance. + +For example, instead of using `map(int, ...)`, the same functionality could be achieved with a +list comprehension, like so: + +D[i] = tuple([int(digit) for digit in convert_to_base(i, base)]) + +This list comprehension achieves the same result but follows a more modern Pythonic style. + +### Standard Solution + +```python +def f4(n, base): + D = {0: (0,)} + for m in range(1, n + 1): + digits = [] + p = m + while p: + digits.append(p % base) + p //= base + D[m] = tuple(reversed(digits)) + return D +``` + +Both solutions are valid and achieve the same result. My approach uses a helper function for base conversion, which adds modularity, +whereas the standard solution is more concise and directly integrates the conversion logic into the main function. + +# Exercise 5 + +At the first, try to run this: + +```python +print(0.1 + 0.2) +``` + +What happened? The result is not 0.3, but 0.30000000000000004. Why? + +### Problem Description + +The approach we are using in this exercise is designed to expose the limitations of floating-point arithmetic in computers. Let's break down why this approach leads to precision inaccuracies and why other methods might not reveal these issues as clearly. + +This problem can seem complex, and it's designed to highlight the subtleties of floating-point arithmetic. Let's walk through the logic using the test cases to figure out what the function does. + +### Key Concepts + +- **Floating-point numbers**: Computers store floating-point numbers using a binary format, which often introduces precision errors. +- **Precision**: We're working with two types of precision in this function — simple precision (same as the length of the fractional part) and double precision (twice that length). + +### Solution + +```python +def f5(integral_part, fractional_part): + # Calculate the number of digits in the fractional part + precision = len(str(fractional_part)) + + # Concatenate the integral and fractional parts as strings, then convert to a float + a_float = float(str(integral_part) + '.' + str(fractional_part)) + + # Format the float with precision equal to the number of digits in the fractional part (simple precision) + simple_precision = f'{a_float:.{precision}f}' + + # Append a number of zeros equal to the fractional part length to the simple precision value (extended precision) + extended_simple_precision = simple_precision + '0' * precision + + # Format the float with precision equal to twice the number of fractional digits (double precision) + double_precision = f'{a_float:.{precision * 2}f}' + + # Print the first part of the output + print('With', precision * 2, 'digits after the decimal point, ', end='') + + # Compare if extended precision and double precision values are the same + if extended_simple_precision == double_precision: + # If they are the same, it means the float is precise and has trailing zeros + print(simple_precision, 'prints out with', precision, 'trailing', + precision == 1 and 'zero,' or 'zeroes,', 'namely, as', + extended_simple_precision + ) + else: + # If not, there is a precision error, and no trailing zeros + print(simple_precision, 'prints out as', double_precision) +``` + +Our function attempts to check and display this floating point error with simple precision (`simple_precision`) and double precision (`double_precision`). The error becomes more obvious when we represent floating point numbers with higher precision (double the number of decimal places). So in this way, we show that floating point numbers are not always actually stored as we expect them to be with more precise representation. + +# Exercise 6 + +### Problem Description + +In this task, we are given: + +- A list `L`, which contains multiple sub-lists of integers, and all sub-lists have the same length `n`. +- A list `fields`, which is a permutation of `{1, ..., n}`. + +We are required to sort the list L by using a multi-key sorting mechanism, where: + +- First, the elements in `L` are sorted based on the position given by the first element of `fields`. +- If two sub-lists are equal based on the first field, we move to the second field, and so on. +- Finally, if required, the sorting proceeds up to the last field in `fields`. + +### Example of Fields Explanation + +If `fields = [2, 1]`, it means: + +1. First, sort based on the second element of each sublist. +2. If there are ties (same values in the second position), sort based on the first element. + +### My Solution + +```python +def f6(L, fields): + return sorted(L, key=lambda x: [x[i-1] for i in fields]) +``` + +1. Sorting with sorted(): + The `sorted()` function is used to sort the list `L`. + The key parameter defines how the sorting will be performed. + +2. Lambda Function: + The lambda function defines how the sublists will be sorted. It generates a list of values for each sublist based on the positions specified in `fields`. + For example, if `fields = [2, 1]`, the lambda function will extract the second and first elements from each sublist in that order, and sorting will be done based on this new list. + +3. Key Structure: + The key is a list of elements from each sublist, indexed by the positions specified in fields. We use `x[i - 1]` because fields is `1-based`, and list indexing in Python is `0-based`. + +4. What is a Lambda Function? + +For example: + +We have: + +```python +f = lambda x: x * x +``` + +This is equivalent to: + +```python +def f(x): + return x * x +``` + +And lambda function in a sorted function is used to define a custom sorting key. + +```python +L = [(1,2), (3,1), (5,0)] + +SortedL = sorted(L, key=lambda x: x[1]) + +print(SortedL) +``` + +The result is: `[(5, 0), (3, 1), (1, 2)]`, it sorts the list based on the second element of each tuple. + +### Standard Solution + +```python +def f6(L, fields): + return sorted(L, key=lambda x: tuple(x[i - 1] for i in fields)) +``` + +**Why Use a Tuple?**: + +- Tuples are often preferred for multi-key sorting because they are immutable, and Python's built-in sorting functions can efficiently compare tuples. +- Each sublist is transformed into a tuple of its elements based on the order defined by fields. The sorted() function then uses these tuples to sort the list. diff --git a/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.md b/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.md index 1aa208c4..0c50ebb9 100644 --- a/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.md +++ b/content/docs/career/interview-prep/leetcode/9021_TUT_3_25T1.md @@ -1,5 +1,6 @@ --- title: 9021_TUT_3_25T1.md +description: "LeetCode 9021. 题解 — 构造重复单元拼接字符串,使用列表生成与字符串 join 方法分解单元结构,适合算法初学者与备考编程面试的读者巩固基础字符串操作与分治思维。" date: 2025/3/07 tags: - "9021" diff --git a/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.en.md b/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.en.md new file mode 100644 index 00000000..738bda89 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.en.md @@ -0,0 +1,62 @@ +--- +title: "93. Restore IP Addresses" +description: "LeetCode 93. Restore IP Addresses — backtracking algorithm (DFS) with recursion over all possible IP segment combinations. Focuses on pointer movement, substring slicing, and the implementation detail that pass-by-value with list concatenation eliminates the need to manually undo state. Suitable for CS/AI job seekers preparing for big-tech algorithm interviews who are grinding backtracking problems on LeetCode." +date: "2025/3/25-14:03" +tags: + - - Python + - - Answer +abbrlink: 9d0d3b9c +docId: d5evrnoglwjvmyginjq84bl0 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem + +[93. Restore IP Addresses](https://leetcode.cn/problems/restore-ip-addresses/description/?envType=company&envId=mihoyo&favoriteSlug=mihoyo-all) + +# Approach + +This MiHoYo coding test question is very similar to LeetCode 46 (Permutations), and both rely on the backtracking approach. + +As shown in the code, during the first traversal, we may get something like `['2', '5', '5', '2']` as our initial parts, but at this point we haven't traversed the entire string yet. + +When we enter the next level of DFS, the pointer moves forward by `+length`, effectively pointing to the far right of the current segment. If the pointer has reached the end of the string, it means we've visited all characters — we've found one valid answer and can add it to the result list. + +One important note: `parts + [part]` is pass-by-value, not by reference like in LeetCode 46. This means we don't need to manually undo changes (no need to backtrack with `pop()`), because each recursive call creates a new list. + +# Code + +```python +from typing import List + +class Solution: + def restoreIpAddresses(self, s: str) -> List[str]: + res = [] + + def backtrack(start: int, parts: List[str]): + # 终止条件:正好4段且用完所有字符 + # Stop condition: exactly 4 segments and all characters used up + if len(parts) == 4: + if start == len(s): + res.append(".".join(parts)) + return + + for length in range(1, 4): # 每段长度1~3 Each segment length 1~3 + if start + length > len(s): + break + part = s[start:start+length] + + # 前导0非法,但0本身合法 + # Leading 0 is illegal, but 0 itself is legal + if len(part) > 1 and part[0] == '0': + continue + + if int(part) <= 255: + backtrack(start + length, parts + [part]) # 注意用 + 避免污染 We need to use + to avoid pollution + + backtrack(0, []) + return res +``` diff --git a/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.zh.md b/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.zh.md index bc7a86ba..c8a7cd4f 100644 --- a/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.zh.md +++ b/content/docs/career/interview-prep/leetcode/93-restore-ip-addresses.zh.md @@ -1,5 +1,6 @@ --- title: "93. 复原 IP 地址" +description: "LeetCode 93. 复原 IP 地址 题解 — 回溯算法 + DFS 深度优先遍历,通过逐段截取字符串并检查每段是否合法(0-255 且无前导零)来生成所有可能的 IP 组合。适合准备大厂笔试、面试的求职者,以及需要巩固回溯思想与字符串分割技巧的算法学习者。" date: "2025/3/25-14:03" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.en.md" "b/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.en.md" new file mode 100644 index 00000000..1eeaa681 --- /dev/null +++ "b/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.en.md" @@ -0,0 +1,64 @@ +--- +title: "93. Restore IP Addresses" +description: "LeetCode 93. Restore IP Addresses — backtracking algorithm (DFS) in depth: recursively iterates through all possible IP segment combinations, with emphasis on pointer movement, string slicing techniques, and the implementation detail that pass-by-value eliminates manual state rollback. Suitable for CS/AI job seekers preparing for big-tech algorithm interviews who are grinding LeetCode backtracking problems." +date: "2025/3/25-14:03" +tags: + - - Python + - - Answer +abbrlink: 9d0d3b9c +docId: d5evrnoglwjvmyginjq84bl0 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# QUESTION + +[93. Restore IP Addresses](https://leetcode.cn/problems/restore-ip-addresses/description/?envType=company&envId=mihoyo&favoriteSlug=mihoyo-all) + +# My Think + +This MiHoYo coding test question is very similar to LeetCode 46 (Permutations), and both rely on the backtracking approach. + +As shown in the code, during the first traversal, we may get something like `['2', '5', '5', '2']` as our initial parts, but at this point, we haven't traversed the entire string yet. + +When we enter the next level of DFS, the pointer moves forward by +length, so it effectively moves to the far right of the current segment. +If the pointer has reached the end of the string, it means we've visited all characters — in this case, we've found one valid answer and can add it to the result list. + +One important note: `parts + [part]` is pass-by-value, not by reference like in LeetCode 46. +This means we don't need to manually undo changes (i.e., no need to backtrack with pop()), because each recursive call creates a new list. + +# Code + +```python +from typing import List + +class Solution: + def restoreIpAddresses(self, s: str) -> List[str]: + res = [] + + def backtrack(start: int, parts: List[str]): + # 终止条件:正好4段且用完所有字符 + # Stop condition: exactly 4 segments and all characters used up + if len(parts) == 4: + if start == len(s): + res.append(".".join(parts)) + return + + for length in range(1, 4): # 每段长度1~3 Each segment length 1~3 + if start + length > len(s): + break + part = s[start:start+length] + + # 前导0非法,但0本身合法 + # Leading 0 is illegal, but 0 itself is legal + if len(part) > 1 and part[0] == '0': + continue + + if int(part) <= 255: + backtrack(start + length, parts + [part]) # 注意用 + 避免污染 We need to use + to avoid pollution + + backtrack(0, []) + return res +``` diff --git "a/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.md" "b/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.md" index c6fc4bcd..2e42cb43 100644 --- "a/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.md" +++ "b/content/docs/career/interview-prep/leetcode/93\345\244\215\345\216\237Ip\345\234\260\345\235\200.md" @@ -1,5 +1,6 @@ --- title: 93. Restore IP Addresses +description: "LeetCode 93. Restore IP Addresses 题解 — 回溯算法(DFS)深度解析,通过递归遍历所有可能的IP分段组合,重点讲解指针移动与字符串截断技巧,以及值传递下无需手动撤销操作的实现细节。适合正在刷LeetCode回溯类题目、准备大厂算法面试的CS/AI求职者。" date: "2025/3/25-14:03" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/994-rotting-oranges.en.md b/content/docs/career/interview-prep/leetcode/994-rotting-oranges.en.md index d540206a..40824c64 100644 --- a/content/docs/career/interview-prep/leetcode/994-rotting-oranges.en.md +++ b/content/docs/career/interview-prep/leetcode/994-rotting-oranges.en.md @@ -1,5 +1,6 @@ --- title: "994. Rotting Oranges" +description: "LeetCode 994. Rotting Oranges — BFS multi-source approach to simulate minute-by-minute spread, tracking time and checking unreachable fresh oranges." date: "2024.05.14 0:00" tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/994.\350\205\220\347\203\202\347\232\204\346\251\230\345\255\220_translated.md" "b/content/docs/career/interview-prep/leetcode/994.\350\205\220\347\203\202\347\232\204\346\251\230\345\255\220_translated.md" index 235b9d87..4515780f 100644 --- "a/content/docs/career/interview-prep/leetcode/994.\350\205\220\347\203\202\347\232\204\346\251\230\345\255\220_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/994.\350\205\220\347\203\202\347\232\204\346\251\230\345\255\220_translated.md" @@ -1,5 +1,6 @@ --- title: 994.Rotten orange.md +description: "LeetCode 994. 腐烂的橘子 题解 — 多源 BFS 广度优先搜索模拟腐烂扩散过程,使用队列同时从所有初始腐烂橘子出发逐层感染,统计新鲜橘子全部腐烂所需最小分钟数。适合准备面试、刷图论与BFS算法题的求职者和CS/AI学习者。" date: "2024.05.14 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.en.md b/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.en.md new file mode 100644 index 00000000..aff406ea --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.en.md @@ -0,0 +1,63 @@ +--- +title: Counting Stars — Inter-Uni Programming Contest +description: "LeetCode solution — Counting Stars Inter-University Programming Contest. Restores meteor trajectories using a sort-and-greedy strategy: after sorting points by increasing x-coordinate, maintain the last y-coordinate of the current chain to determine whether a new point can extend an existing meteor path, computing the minimum number of stars required. Ideal for CS learners preparing for algorithm competitions and practicing greedy and sorting techniques." +date: 22/9/2024 +tags: + - Contest + - Python + - Binary Search +abbrlink: a29b0a05 +docId: fostlzqqx6l10qz1egd8dw5m +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Description: + +https://interunia.unswcpmsoc.com/task/Counting%20Stars/ + +# Thinking: + +- Given a set of star positions, we need to calculate the minimum number of stars required to explain these positions. +- Meteors (i.e., moving stars) move from left to right, and from high to low (x coordinates increase, y coordinates decrease), without moving horizontally or vertically. +- Each meteor may appear in multiple positions (because it moves), and the final cumulative image will show all the positions it has passed through. +- The positions of fixed stars remain unchanged. + +Therefore, we need to maintain a list of the **last y-coordinate of the current chain**. + +1. **Sort the points**: Sort them by increasing x coordinates. +2. **Initialization**: Create an empty list `last_y` to store the last y-coordinate of each chain. +3. **Traverse the set of points**: + - For each point (x, y): + - Use `bisect_right` to find the first position in `last_y` that is greater than the current y. + - If the index is less than the length of `last_y`, it means there is an existing chain that can accommodate the current point, so we update the last y-coordinate of that chain to the current y. + - If the index is equal to the length of `last_y`, it means no suitable chain is found, so we need to create a new chain and add the current y to `last_y`. + +# Code: + +```python +import bisect + +n = int(input()) +stars = [] + +for _ in range(n): + x, y = map(int, input().split()) + stars.append((x, y)) + +# 按 x 坐标递增排序 +stars.sort(key=lambda x: (x[0],)) + +last_y = [] + +for x, y in stars: + idx = bisect.bisect_right(last_y, y) + if idx < len(last_y): + last_y[idx] = y # 更新链的最后一个 y 坐标 + else: + last_y.append(y) # 创建新的链 + +print(len(last_y)) +``` diff --git a/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.md b/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.md index 828ace9c..6b6e0b98 100644 --- a/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.md +++ b/content/docs/career/interview-prep/leetcode/Counting Stars-Inter-Uni Programming Contest.md @@ -1,5 +1,6 @@ --- title: Counting Stars-Inter-Uni Programming Contest.md +description: "LeetCode 题解 — 基于排序与贪心策略的流星轨迹还原问题。通过按 x 坐标递增排序后维护当前链的最后 y 坐标,判断新点能否接续已有流星路径,从而计算最少所需恒星数量。适合备战算法竞赛、练习贪心与排序技巧的 CS 学习者。" date: 22/9/2024 tags: - Contest diff --git "a/content/docs/career/interview-prep/leetcode/[121]\344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\237_translated.md" "b/content/docs/career/interview-prep/leetcode/[121]\344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\237_translated.md" index db8fd02b..ed2e9a90 100644 --- "a/content/docs/career/interview-prep/leetcode/[121]\344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\237_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[121]\344\271\260\345\215\226\350\202\241\347\245\250\347\232\204\346\234\200\344\275\263\346\227\266\346\234\237_translated.md" @@ -1,5 +1,6 @@ --- title: 121.The best time for buying and selling stocks +description: "LeetCode 121. 买卖股票的最佳时机 题解 — 使用动态规划(DP)求解单次交易最大利润,核心技巧是维护历史最低股价并实时计算当日卖出收益。适合准备算法面试、刷 LeetCode 数组与 DP 题的求职者和 CS 学生。" date: "2024.01.01 0:00" tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/[1333]\351\244\220\345\216\205\350\277\207\346\273\244\345\231\250_translated.md" "b/content/docs/career/interview-prep/leetcode/[1333]\351\244\220\345\216\205\350\277\207\346\273\244\345\231\250_translated.md" index 34537104..15c06863 100644 --- "a/content/docs/career/interview-prep/leetcode/[1333]\351\244\220\345\216\205\350\277\207\346\273\244\345\231\250_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[1333]\351\244\220\345\216\205\350\277\207\346\273\244\345\231\250_translated.md" @@ -1,5 +1,6 @@ --- title: 1333.Restaurant filter +description: "LeetCode 1333. 餐厅过滤器 题解 — 使用列表推导式与排序优化过滤逻辑,关键技巧包括利用 sorted 与 lambda 实现多级排序(先按评分降序、再按 id 降序),适合准备算法面试、希望提升 Python 代码效率的 LeetCode 刷题者阅读。" date: "2024.01.01 0:00" tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/[146]LRU \347\274\223\345\255\230_translated.md" "b/content/docs/career/interview-prep/leetcode/[146]LRU \347\274\223\345\255\230_translated.md" index 1f9a315e..1453346a 100644 --- "a/content/docs/career/interview-prep/leetcode/[146]LRU \347\274\223\345\255\230_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[146]LRU \347\274\223\345\255\230_translated.md" @@ -1,5 +1,6 @@ --- title: 146.LRU cache +description: "LeetCode 146. LRU 缓存 题解 — 使用哈希表 + 双向链表实现 O(1) 时间复杂度的 get 和 put 操作,核心技巧是维护最近最少使用顺序。适合准备面试、需要掌握 LRU 缓存机制与链表操作的算法学习者。" date: "2024.01.01 0:00" tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.en.md" "b/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.en.md" new file mode 100644 index 00000000..02ec4bdb --- /dev/null +++ "b/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.en.md" @@ -0,0 +1,146 @@ +--- +title: "1545. Find Kth Bit in Nth Binary String" +description: "LeetCode 1545 solution — Find Kth Bit in Nth Binary String. Uses recursion and mathematical bit-flipping: by analyzing the string construction pattern (S₁=0, each subsequent string is the previous string + 1 + reverse-invert of the previous string), the k-th bit is classified into left half, middle, or right half and solved recursively, avoiding the memory overflow caused by brute-force generation. Ideal for algorithm learners preparing for interviews and practicing recursion and bit manipulation." +date: "2026.03.04 00:46" +tags: + - Leetcode + - answer + - Math + - String +docId: zuoplhoodv7tzfgku0pwzi6w +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem + +Given two positive integers `n` and `k`, the binary string `Sn` is formed according to the following rules: + +- `S1 = "0"` +- When `i > 1`: `Si = Si-1 + "1" + reverse(invert(Si-1))` + +where `+` denotes concatenation, `reverse(x)` returns the string `x` reversed, and `invert(x)` flips every bit in `x` (0 becomes 1 and 1 becomes 0). + +The first 4 strings in this sequence are: + +- S1 = "0" +- S2 = "011" +- S3 = "0111001" +- S4 = "011100110110001" + +Return the `k`-th bit in `Sn`. It is guaranteed that `k` is within the valid range for `Sn`. + +# Solution + +My first attempt was a brute-force approach — directly generating `Sn`. However, when `n` is large, `Sn` becomes extremely long, causing memory overflow. + +```javascript +/** + * @param {number} n + * @param {number} k + * @return {character} + */ +var findKthBit = function (n, k) { + var reverseR = function (input) { + return input + .split("") // 拆分成数组 ["0", "1", "1", "1", "0"] + .map((char) => char ^ 1) // 翻转每一位: [1, 0, 0, 0, 1] + .reverse() // 反转数组顺序: [1, 0, 0, 0, 1] + .join(""); // 拼回字符串 "10001" + }; + let S = "0"; + for (let i = 1; i < n; i++) { + S = S + "1" + reverseR(S); + } + return S[k - 1]; +}; +``` + +I then tried a mathematical bit-flip approach. Observing $S_i = S_{i-1} + "1" + \text{reverse}(\text{invert}(S_{i-1}))$: + +Length pattern: $|S_n| = 2^n - 1$. + +- For example, $S_1$ has length $2^1-1=1$, and its middle bit is position $1$. +- $S_2$ has length $2^2-1=3$, and its middle bit is position $2$. +- $S_3$ has length $2^3-1=7$, and its middle bit is position $4$. + +Three cases for the position of `k`: + +- **Left half** ($k < mid$): This is an exact copy of $S_{n-1}$, so we simply ask "what is the $k$-th bit of $S_{n-1}$?" +- **Middle** ($k = mid$): By the construction rule, this bit is always `"1"`. +- **Right half** ($k > mid$): This is the most elegant part. The right half is the reverse-invert of $S_{n-1}$. + +Because of the **reverse**, the 1st character of the right half corresponds to the last character of the left half, and so on. + +The mapping formula is: $S_n[k] = \text{invert}(S_{n-1}[2^n - k])$. + +For example, to find the 6th bit in $S_3$ (length 7), it corresponds to the result of inverting the $2^3 - 6 = 2$nd bit of $S_2$. + +```javascript +var findKthBit = function (n, k) { + let flip = false; // 记录需要取反的次数 + while (n > 1) { + let mid = 1 << (n - 1); // 2^(n-1) + if (k === mid) { + // 中间位固定为 1 + let res = 1; + return (flip ? res ^ 1 : res).toString(); + } else if (k > mid) { + // 如果在右侧,镜像到左侧,并增加一次取反 + k = 2 * mid - k; + flip = !flip; + } + // 如果在左侧,直接继续看 n-1 + n--; + } + // 最终回到 S1,S1 是 "0" + let res = 0; + return (flip ? res ^ 1 : res).toString(); +}; +``` + +## Why Is `mid` Equal to $2^{n-1}$? + +We can derive the center point (mid) by computing the total length of $S_n$. + +**Computing the length of $S_n$**: Let $L_n$ denote the length of the $n$-th string $S_n$. From the problem rules: + +- $S_1 = "0"$, so $L_1 = 1$ +- $S_n = S_{n-1} + "1" + \text{modified } S_{n-1}$ + +The length recurrence is: $$L_n = L_{n-1} (\text{left half}) + 1 (\text{middle}) + L_{n-1} (\text{right half})$$ i.e., $L_n = 2 \times L_{n-1} + 1$ + +Listing out the values: + +- $L_1 = 1$ +- $L_2 = 2 \times 1 + 1 = 3$ +- $L_3 = 2 \times 3 + 1 = 7$ +- $L_4 = 2 \times 7 + 1 = 15$ + +Pattern: $L_n = 2^n - 1$ + +## 2. Why Do We Search This Way? + +Think of it like finding a specific point on an infinitely folded paper strip: + +- **Old approach (simulation)**: Fold a blank sheet of paper 20 times to create an enormously long strip, then count from the beginning to the $k$-th point. +- **New approach (backtracking/iteration)**: Look at the already "folded" paper ($S_n$) and ask: is this point $k$ to the left or right of the fold? + - If it is to the right of the fold, "unfold" it back to the left (mirror mapping) and record that it was flipped once (`flip = !flip`). + - If it is to the left, just look directly at the left half. + - Now the paper is half the size (`n--`), and you repeat the process until you land exactly on the fold (`k === mid`) or the paper shrinks to its smallest possible size (`n=1`). + +## 3. If We Are in the Right Half and `S[k]=0`, Does Flipping Over Mean `S[k]=1`? + +Why does "flipping over" give us 1? + +According to the problem, the right half of $S_i$ is: $\text{reverse}(\text{invert}(S_{i-1}))$. There are two operations here: + +- **Invert**: $0 \to 1$, $1 \to 0$. +- **Reverse**: positions are mirrored left-to-right. + +So if we see a 0 in the right half and trace it back through these two operations: + +- Because of **invert**: it was a 1 before being flipped. +- Because of **reverse**: its corresponding position is the symmetric point in the left half. diff --git "a/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.md" "b/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.md" index 743411cc..ddaf8bf2 100644 --- "a/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.md" +++ "b/content/docs/career/interview-prep/leetcode/[1545]\346\211\276\345\207\272\347\254\254 N \344\270\252\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\344\270\255\347\232\204\347\254\254 K \344\275\215.md" @@ -1,5 +1,6 @@ --- title: 1545. 找出第 N 个二进制字符串中的第 K 位 +description: "LeetCode 1545. 找出第 N 个二进制字符串中的第 K 位 题解 — 递归与数学翻转解法,通过分析字符串构造规律(S₁=0,后续由前序+1+反转取反前序组成),将第 K 位分为左半、中间、右半三类递归求解,避免暴力生成导致内存溢出。适合准备面试、刷递归与位运算题型的算法学习者。" date: "2026.03.04 00:46" tags: - Leetcode diff --git "a/content/docs/career/interview-prep/leetcode/[213]\346\211\223\345\256\266\345\212\253\350\210\215 II_translated.md" "b/content/docs/career/interview-prep/leetcode/[213]\346\211\223\345\256\266\345\212\253\350\210\215 II_translated.md" index 112d6296..bb23ca51 100644 --- "a/content/docs/career/interview-prep/leetcode/[213]\346\211\223\345\256\266\345\212\253\350\210\215 II_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[213]\346\211\223\345\256\266\345\212\253\350\210\215 II_translated.md" @@ -1,5 +1,6 @@ --- title: 213.Hiccup II +description: "LeetCode 213. 打家劫舍 II 题解 — 动态规划解决环形街区偷窃问题,核心技巧是将环形拆分为两个线性子问题:分别考虑不偷第一间和不偷最后一间,再取最大值。适合正在刷 LeetCode 动态规划题、准备算法面试的 CS 求职者。" date: "2024.01.01 0:00" tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/[2490]\345\233\236\347\216\257\345\217\245_translated.md" "b/content/docs/career/interview-prep/leetcode/[2490]\345\233\236\347\216\257\345\217\245_translated.md" index fff4539f..9602751b 100644 --- "a/content/docs/career/interview-prep/leetcode/[2490]\345\233\236\347\216\257\345\217\245_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[2490]\345\233\236\347\216\257\345\217\245_translated.md" @@ -1,5 +1,6 @@ --- title: 2490Return ring sentence +description: "LeetCode 2490. 回环句 题解 — 判断句子是否为回环句,核心解法为分割单词后检查每个单词末字母与下一单词首字母是否相同,涉及字符串分割与双指针遍历技巧。适合正在刷 LeetCode 字符串类题目的求职者与算法学习者。" date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/[2562]\346\211\276\345\207\272\346\225\260\347\273\204\347\232\204\344\270\262\350\201\224\345\200\274_translated.md" "b/content/docs/career/interview-prep/leetcode/[2562]\346\211\276\345\207\272\346\225\260\347\273\204\347\232\204\344\270\262\350\201\224\345\200\274_translated.md" index 54ae9792..06c272a2 100644 --- "a/content/docs/career/interview-prep/leetcode/[2562]\346\211\276\345\207\272\346\225\260\347\273\204\347\232\204\344\270\262\350\201\224\345\200\274_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[2562]\346\211\276\345\207\272\346\225\260\347\273\204\347\232\204\344\270\262\350\201\224\345\200\274_translated.md" @@ -1,5 +1,6 @@ --- title: 2562.Find the series of the array +description: "LeetCode 2562. 找出数组的串联值 题解 — 使用双指针技巧从数组两端逐步取出数字并拼接为串联值,关键点在于正确处理正负索引的转换关系,避免越界错误。适合正在刷 LeetCode 双指针题型、需要巩固数组索引边界处理的求职者和算法学习者。" date: "2024.01.01 0:00" tags: - Python diff --git "a/content/docs/career/interview-prep/leetcode/[2582]\351\200\222\346\236\225\345\244\264_translated.md" "b/content/docs/career/interview-prep/leetcode/[2582]\351\200\222\346\236\225\345\244\264_translated.md" index 60ac06d9..e15fbac0 100644 --- "a/content/docs/career/interview-prep/leetcode/[2582]\351\200\222\346\236\225\345\244\264_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/[2582]\351\200\222\346\236\225\345\244\264_translated.md" @@ -1,5 +1,6 @@ --- title: 2582.Pillow +description: "LeetCode 2582. 递枕头 题解 — 数学规律题,核心技巧是利用 n 个人传枕头时每轮间隔为 n-1,通过 time // (n-1) 计算完整轮次,再根据轮次奇偶性判断正向或反向传递位置。适合正在刷 LeetCode 数学模拟类题目的求职者与算法学习者。" date: "2024.01.01 0:00" tags: - Python diff --git a/content/docs/career/interview-prep/leetcode/brief-alternate-homework-help.en.md b/content/docs/career/interview-prep/leetcode/brief-alternate-homework-help.en.md index 0158cad1..3aabf590 100644 --- a/content/docs/career/interview-prep/leetcode/brief-alternate-homework-help.en.md +++ b/content/docs/career/interview-prep/leetcode/brief-alternate-homework-help.en.md @@ -1,5 +1,6 @@ --- title: "Brief Alternate Assignment Help" +description: "LeetCode 0. Brief Alternate Assignment Help — Use pandas for data processing: `read_csv` auto-assigns headers, `idxmax`/`max` for row/value extraction, `loc` for label-based selection, and `nunique` for unique counts. For self-taught learners." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/brief_alternate \344\275\234\344\270\232\345\270\256\345\277\231_translated.md" "b/content/docs/career/interview-prep/leetcode/brief_alternate \344\275\234\344\270\232\345\270\256\345\277\231_translated.md" index e0b56c6c..86bc0ab4 100644 --- "a/content/docs/career/interview-prep/leetcode/brief_alternate \344\275\234\344\270\232\345\270\256\345\277\231_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/brief_alternate \344\275\234\344\270\232\345\270\256\345\277\231_translated.md" @@ -1,5 +1,6 @@ --- title: brief_alternate Assignment +description: 'LeetCode 题解 — 基于 pandas 的数据处理与求职面试实战题解。讲解如何使用 df["Name"] 直接提取列、idxmax() 与 max() 获取最大值索引与数值,以及 .loc 函数进行行列定位与筛选。适合正在刷 LeetCode 数据科学题、准备 AI/数据分析岗位面试的求职者与自学者。' date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.en.md b/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.en.md new file mode 100644 index 00000000..dad070cf --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.en.md @@ -0,0 +1,63 @@ +--- +title: "Counting Stars — Inter-University Programming Contest" +description: "LeetCode solution — Counting Stars Inter-University Programming Contest. Uses a greedy algorithm with binary search to maintain a list of chain-tail y-coordinates. After sorting points, traverse the point set and use bisect_left to find chains that can accommodate the current point, then solve for the minimum number of meteors. Ideal for CS students preparing for algorithm competitions and learning greedy + binary search techniques." +date: 22/9/2024 +tags: + - Contest + - Python + - Binary Search +abbrlink: a29b0a05 +docId: fostlzqqx6l10qz1egd8dw5m +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# Problem Description + +https://interunia.unswcpmsoc.com/task/Counting%20Stars/ + +# Approach + +- Given a set of star positions, we need to calculate the minimum number of stars required to explain these positions. +- Meteors (i.e., moving stars) move from left to right and from high to low (x coordinates increase, y coordinates decrease), without horizontal or vertical movement. +- Each meteor may appear at multiple positions (because it moves), and the final accumulated image shows all positions it has passed through. +- Fixed stars remain stationary. + +Therefore, we need to maintain a **list of the last y-coordinate of the current chain**. + +1. **Sort the points**: Sort by increasing x coordinate. +2. **Initialization**: Create an empty list `last_y` to store the last y-coordinate of each chain. +3. **Traverse the point set**: + - For each point `(x, y)`: + - Use `bisect_right` to find the first position in `last_y` that is greater than the current y. + - If the index is less than the length of `last_y`, there exists a chain that can accommodate the current point — update that chain's last y-coordinate to the current y. + - If the index equals the length of `last_y`, no suitable chain exists — create a new chain and append the current y to `last_y`. + +# Code + +```python +import bisect + +n = int(input()) +stars = [] + +for _ in range(n): + x, y = map(int, input().split()) + stars.append((x, y)) + +# 按 x 坐标递增排序 +stars.sort(key=lambda x: (x[0],)) + +last_y = [] + +for x, y in stars: + idx = bisect.bisect_right(last_y, y) + if idx < len(last_y): + last_y[idx] = y # 更新链的最后一个 y 坐标 + else: + last_y.append(y) # 创建新的链 + +print(len(last_y)) +``` diff --git a/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.zh.md b/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.zh.md index 39919ad0..aa875909 100644 --- a/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.zh.md +++ b/content/docs/career/interview-prep/leetcode/counting-stars-inter-uni-programming-contest.zh.md @@ -1,5 +1,6 @@ --- title: "Counting Stars — 校际编程竞赛" +description: "LeetCode 题解 — Counting Stars 校际编程竞赛题解。使用贪心算法与二分查找维护链尾 y 坐标列表,通过排序后遍历点集并利用 bisect_left 寻找可容纳当前点的链,求解最少流星数量。适合准备算法竞赛、学习贪心与二分查找技巧的 CS 学生阅读。" date: 22/9/2024 tags: - Contest diff --git a/content/docs/career/interview-prep/leetcode/index.en.mdx b/content/docs/career/interview-prep/leetcode/index.en.mdx new file mode 100644 index 00000000..2a833168 --- /dev/null +++ b/content/docs/career/interview-prep/leetcode/index.en.mdx @@ -0,0 +1,17 @@ +--- +title: LeetCode Solutions +description: "A curated collection of LeetCode solutions covering dynamic programming, sliding window, two pointers, graph algorithms, and more — with in-depth explanations of arrays, linked lists, hash tables, stacks, and other data structures. Ideal for CS job seekers preparing for technical interviews and algorithm learners looking to level up." +docId: aslw60tfyzxqga598pt4ociu +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +import { SectionIndex } from "@/app/components/docs/SectionIndex"; + +# LeetCode Solutions + +Welcome to the LeetCode solutions section. + + diff --git a/content/docs/career/interview-prep/leetcode/index.mdx b/content/docs/career/interview-prep/leetcode/index.mdx index 03f849c9..9b752deb 100644 --- a/content/docs/career/interview-prep/leetcode/index.mdx +++ b/content/docs/career/interview-prep/leetcode/index.mdx @@ -1,6 +1,6 @@ --- title: Leetcode 题解汇总 -description: 这里收集了社区分享的所有 Leetcode 刷题笔记和题解。 +description: "LeetCode 题解汇总 — 覆盖动态规划、滑动窗口、双指针、图论等高频算法,详解数组、链表、哈希表、堆栈等数据结构实战技巧,适合准备技术面试的 CS 求职者与刷题进阶的算法学习者。" docId: aslw60tfyzxqga598pt4ociu --- diff --git a/content/docs/career/interview-prep/leetcode/sword-offer-ii-021-remove-nth-node-from-end-of-list.en.md b/content/docs/career/interview-prep/leetcode/sword-offer-ii-021-remove-nth-node-from-end-of-list.en.md index 565b3b37..6370b31b 100644 --- a/content/docs/career/interview-prep/leetcode/sword-offer-ii-021-remove-nth-node-from-end-of-list.en.md +++ b/content/docs/career/interview-prep/leetcode/sword-offer-ii-021-remove-nth-node-from-end-of-list.en.md @@ -1,5 +1,6 @@ --- title: "Sword Offer II 021. Remove the Nth Node From End of List" +description: "LeetCode Sword Offer II 021. Remove the Nth Node From End of List — Two pointers sliding window with dummy head node to delete nth node from end in one pass, for Python/Java/C++ coders." date: "2024.01.01 0:00" tags: - - Python diff --git "a/content/docs/career/interview-prep/leetcode/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271_translated.md" "b/content/docs/career/interview-prep/leetcode/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271_translated.md" index ec7fc7b6..1d957d18 100644 --- "a/content/docs/career/interview-prep/leetcode/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271_translated.md" +++ "b/content/docs/career/interview-prep/leetcode/\345\211\221\346\214\207 Offer II 021. \345\210\240\351\231\244\351\223\276\350\241\250\347\232\204\345\200\222\346\225\260\347\254\254 n \344\270\252\347\273\223\347\202\271_translated.md" @@ -1,5 +1,6 @@ --- title: Sword finger Offer II 021. Delete the countdown of the linked list n Node.md +description: "LeetCode 剑指 Offer II 021. 删除链表的倒数第 n 个结点 题解 — 使用双指针(滑动窗口)与虚拟头节点技巧,快指针先走 n 步,再与慢指针同步移动直至快指针到达链表末尾,从而定位并删除倒数第 n 个结点。适合正在刷链表题型、准备算法面试或需要掌握双指针与虚拟头节点用法的读者。" date: "2024.01.01 0:00" tags: - - Python diff --git a/content/docs/career/interview-prep/pre-interview.en.md b/content/docs/career/interview-prep/pre-interview.en.md index 47339507..f70e7a92 100644 --- a/content/docs/career/interview-prep/pre-interview.en.md +++ b/content/docs/career/interview-prep/pre-interview.en.md @@ -1,6 +1,6 @@ --- title: "Must-Read Before Your Interview: Four Tips That Significantly Boost Your Success Rate" -description: "" +description: "Prepare for your next interview with four key tips: strategic company research, competitive insights, and industry trends to boost your success rate. For CS/AI/career learners." date: "2025-09-28" tags: - interview-preparation diff --git a/content/docs/career/interview-prep/pre-interview.md b/content/docs/career/interview-prep/pre-interview.md index 6d2f7a26..1c3ab628 100644 --- a/content/docs/career/interview-prep/pre-interview.md +++ b/content/docs/career/interview-prep/pre-interview.md @@ -1,6 +1,6 @@ --- title: " 面试前必看:掌握这四个小技巧,你的成功率会大大增加" -description: "" +description: "面试前必看:掌握四个小技巧,让你的成功率大大增加。本文详解如何做透背景功课:调研公司业务线、战略举措与竞争格局,以及利用LinkedIn等工具了解面试官履历与关注点。适合正在准备技术面试、希望从众多候选人中脱颖而出的CS/AI求职者阅读。" date: "2025-09-28" tags: - interview-preparation diff --git a/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.en.mdx b/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.en.mdx index a3099c02..db2b4bbc 100644 --- a/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.en.mdx +++ b/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.en.mdx @@ -1,6 +1,6 @@ --- title: A Programmer's Guide to Job Searching and Internships as a Student -description: "" +description: "Student job search guide covering part-time work, internships, and graduate programs with extracurricular tips for securing offers before graduation." date: "2025-09-29" tags: - internship diff --git a/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.mdx b/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.mdx index c0448ba4..5baa0ab1 100644 --- a/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.mdx +++ b/content/docs/career/interview-prep/preparations-to-get-an-offer-as-a-student.mdx @@ -1,6 +1,6 @@ --- title: 程序员学生时期求职与实习经验分享 -description: "" +description: "程序员学生时期求职与实习经验分享:涵盖兼职、助教与New Grad求职准备,重点介绍如何找到第一份实习及提升简历含金量的高性价比路径。适合在校CS学生、准备转码求职者及缺少PR身份需额外准备的求职者阅读。" date: "2025-09-29" tags: - internship diff --git a/content/docs/community/dev-tips/CommonUsedMarkdown.en.md b/content/docs/community/dev-tips/CommonUsedMarkdown.en.md index 8f9f10cf..2388fe57 100644 --- a/content/docs/community/dev-tips/CommonUsedMarkdown.en.md +++ b/content/docs/community/dev-tips/CommonUsedMarkdown.en.md @@ -1,5 +1,6 @@ --- title: Common Markdown Syntax +description: "Learn Markdown syntax for headings, bold, italic, lists, tables, links, and images—perfect for beginners on involutionhell.com." date: 2025-09-20T14:25:39.000Z docId: xqz5iiv3p52h6d9g3c0w2baf lang: en diff --git a/content/docs/community/dev-tips/CommonUsedMarkdown.md b/content/docs/community/dev-tips/CommonUsedMarkdown.md index 8bb02e28..4b7523a8 100644 --- a/content/docs/community/dev-tips/CommonUsedMarkdown.md +++ b/content/docs/community/dev-tips/CommonUsedMarkdown.md @@ -1,5 +1,6 @@ --- title: 常用Markdown语法 +description: "内卷地狱技术文档:常用Markdown语法,涵盖标题字体、加粗斜体删除线、荧光笔与空格、有序无序列表、表格对齐、超链接及图片插入等核心写法。适合CS/AI求职者、开源学习者及文档编写新手快速查阅掌握。" date: 2025-09-20T14:25:39.000Z docId: xqz5iiv3p52h6d9g3c0w2baf --- diff --git a/content/docs/community/dev-tips/Katex/Seb1.en.mdx b/content/docs/community/dev-tips/Katex/Seb1.en.mdx index 70d4352e..ec26ad5d 100644 --- a/content/docs/community/dev-tips/Katex/Seb1.en.mdx +++ b/content/docs/community/dev-tips/Katex/Seb1.en.mdx @@ -1,5 +1,6 @@ --- title: Commonly Used Symbols +description: "Quick reference for Greek letters, arrows, and operators in LaTeX math mode, ideal for students and developers writing technical documentation." date: 2025-09-20T14:25:39.000Z docId: r0inttjcby48tly602p410vo lang: en diff --git a/content/docs/community/dev-tips/Katex/Seb1.mdx b/content/docs/community/dev-tips/Katex/Seb1.mdx index 24a74ffb..ac639c9d 100644 --- a/content/docs/community/dev-tips/Katex/Seb1.mdx +++ b/content/docs/community/dev-tips/Katex/Seb1.mdx @@ -1,5 +1,6 @@ --- title: 个人常用字符 +description: "内卷地狱技术文档页收录个人常用字符速查表,涵盖希腊字母(αβγδθλμπφωΩ)、箭头(←→⇐⇒↔↦⇌)及数学运算符(×∧)的LaTeX指令对照,适合CS/AI学习者与论文写作者快速调用符号代码。" date: 2025-09-20T14:25:39.000Z docId: r0inttjcby48tly602p410vo --- diff --git a/content/docs/community/dev-tips/Katex/Seb2.en.mdx b/content/docs/community/dev-tips/Katex/Seb2.en.mdx index 20518a41..8985a011 100644 --- a/content/docs/community/dev-tips/Katex/Seb2.en.mdx +++ b/content/docs/community/dev-tips/Katex/Seb2.en.mdx @@ -1,5 +1,6 @@ --- title: Math Formula Syntax +description: "Learn LaTeX math formula syntax for summations, products, binomials, matrices, determinants, and aligned equations—ideal for CS/AI students and technical writers." date: 2025-09-20T14:25:39.000Z docId: khcrztruqdku9fntd3dwzvwe lang: en diff --git a/content/docs/community/dev-tips/Katex/Seb2.mdx b/content/docs/community/dev-tips/Katex/Seb2.mdx index 8ec50e5e..d28e3e4e 100644 --- a/content/docs/community/dev-tips/Katex/Seb2.mdx +++ b/content/docs/community/dev-tips/Katex/Seb2.mdx @@ -1,5 +1,6 @@ --- title: 数学公式语法 +description: "内卷地狱技术文档页详解数学公式语法,覆盖求和、求积、二项式、矩阵、行列式、分段函数及等号缩进等LaTeX排版技巧,适合CS/AI求职者、学术写作及技术文档编写者快速查阅与上手。" date: 2025-09-20T14:25:39.000Z docId: khcrztruqdku9fntd3dwzvwe --- diff --git a/content/docs/community/dev-tips/Katex/index.en.mdx b/content/docs/community/dev-tips/Katex/index.en.mdx new file mode 100644 index 00000000..f7596416 --- /dev/null +++ b/content/docs/community/dev-tips/Katex/index.en.mdx @@ -0,0 +1,16 @@ +--- +title: Common KaTeX Syntax +description: "A quick reference for common KaTeX syntax on the Involution Hell documentation site, covering inline math mode and centered display equations — useful for developers learning LaTeX math typesetting, preparing for CS/AI technical assessments, or writing technical documentation." +date: 2025-09-20T14:25:39.000Z +docId: yxd2qpfl2li6092bjx8bz7vb +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +KaTeX differs slightly from LaTeX in certain ways — here is a quick reference for personal use. + +Wrap instructions between two `$` symbols to enable inline math mode, which renders alongside normal text without interruption. + +Wrap instructions between two `$$` symbols to display a formula as a standalone centered block. diff --git a/content/docs/community/dev-tips/Katex/index.mdx b/content/docs/community/dev-tips/Katex/index.mdx index 4a7bbb11..556b7ba9 100644 --- a/content/docs/community/dev-tips/Katex/index.mdx +++ b/content/docs/community/dev-tips/Katex/index.mdx @@ -1,5 +1,6 @@ --- title: 常用Katex语法 +description: "内卷地狱技术文档页详解常用KaTeX语法,涵盖行间数学模式与公式居中显示两大关键操作,适合正在学习LaTeX数学排版、准备CS/AI求职笔试或编写技术文档的开发者快速查阅与复用。" date: 2025-09-20T14:25:39.000Z docId: yxd2qpfl2li6092bjx8bz7vb --- diff --git a/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.en.mdx b/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.en.mdx index cebe0811..fd86a344 100644 --- a/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.en.mdx +++ b/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.en.mdx @@ -1,6 +1,6 @@ --- title: Building a Personal/Team "Permanent" Image Host with Cloudflare R2 + ShareX -description: "" +description: "Build a permanent image host with Cloudflare R2 free tier and ShareX automation for instant screenshot uploads and Markdown links—ideal for devs and teams." date: "2025-09-27" tags: - image-hosting diff --git a/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.mdx b/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.mdx index 860b35ed..82e1da93 100644 --- a/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.mdx +++ b/content/docs/community/dev-tips/cloudflare-r2-sharex-free-image-hosting.mdx @@ -1,6 +1,6 @@ --- title: 使用 Cloudflare R2 + ShareX 搭建个人/团队专属“永久”图床 -description: "" +description: "使用 Cloudflare R2 免费套餐与 ShareX 截图工具搭建个人或团队专属永久图床,实现截图自动上传并返回 Markdown 链接。涵盖 R2 存储桶创建、公开访问权限配置及 ShareX 工作流优化。适合需要低成本、高可控图床的开发者、写作者及技术团队。" date: "2025-09-27" tags: - image-hosting diff --git a/content/docs/community/dev-tips/git101.en.mdx b/content/docs/community/dev-tips/git101.en.mdx index 441c388c..9825d64c 100644 --- a/content/docs/community/dev-tips/git101.en.mdx +++ b/content/docs/community/dev-tips/git101.en.mdx @@ -1,6 +1,6 @@ --- title: Git Getting Started Guide — Git Tips Every Developer Should Know -description: "" +description: "Master Git basics and branching with this open-source guide covering init, commit, push, merge, and rebase for developers learning version control." date: "2025-09-19" tags: - git-basics diff --git a/content/docs/community/dev-tips/git101.mdx b/content/docs/community/dev-tips/git101.mdx index b5f4d225..cbff1320 100644 --- a/content/docs/community/dev-tips/git101.mdx +++ b/content/docs/community/dev-tips/git101.mdx @@ -1,6 +1,6 @@ --- title: Git入门操作指南-程序员必会的git小技巧 -description: "" +description: "Git入门操作指南涵盖Git最常用命令与协作技巧,包括初始化仓库、克隆、暂存提交、分支管理、合并与变基,以及撤销回退、配置别名等进阶操作。适合编程初学者、求职准备者及需要快速掌握Git协作的开发者阅读。" date: "2025-09-19" tags: - git-basics diff --git a/content/docs/community/dev-tips/index.en.mdx b/content/docs/community/dev-tips/index.en.mdx new file mode 100644 index 00000000..ebb053ec --- /dev/null +++ b/content/docs/community/dev-tips/index.en.mdx @@ -0,0 +1,12 @@ +--- +title: Tech Tips +description: "The Tech Tips section of Involution Hell brings together hands-on experience and cutting-edge insights from CS/AI and job-hunting, covering algorithm optimization, system design, and more. A must-read for developers and job seekers preparing for technical interviews or looking to advance their skills." +date: "2025-09-18" +docId: jee9yt8n8tmo8yclqujerw2x +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +Welcome to the Tech Tips section! diff --git a/content/docs/community/dev-tips/index.mdx b/content/docs/community/dev-tips/index.mdx index 0a285ea4..66520d5a 100644 --- a/content/docs/community/dev-tips/index.mdx +++ b/content/docs/community/dev-tips/index.mdx @@ -1,5 +1,6 @@ --- title: 技术分享 +description: "内卷地狱技术分享板块汇集CS/AI/求职领域实战经验与前沿技术解析,涵盖算法优化、系统设计等关键点,适合正在备战面试、追求技术进阶的开发者与求职者深度阅读。" date: "2025-09-18" docId: jee9yt8n8tmo8yclqujerw2x --- diff --git a/content/docs/community/dev-tips/picturecdn.en.mdx b/content/docs/community/dev-tips/picturecdn.en.mdx index 2570e5d7..908ef549 100644 --- a/content/docs/community/dev-tips/picturecdn.en.mdx +++ b/content/docs/community/dev-tips/picturecdn.en.mdx @@ -1,6 +1,6 @@ --- title: How to Deploy Your Own GitHub Image Hosting with PictureCDN -description: "" +description: "Learn to deploy your own GitHub image hosting with PictureCDN for fast, CDN-backed image storage and management—ideal for developers and small websites." date: "2025-09-27" tags: - image-hosting diff --git a/content/docs/community/dev-tips/picturecdn.mdx b/content/docs/community/dev-tips/picturecdn.mdx index 012b9c34..fdd8606e 100644 --- a/content/docs/community/dev-tips/picturecdn.mdx +++ b/content/docs/community/dev-tips/picturecdn.mdx @@ -1,6 +1,6 @@ --- title: 如何部署你自己的Github图床-PictureCDN -description: "" +description: "部署你自己的GitHub图床-PictureCDN:详解图床概念与优势,手把手教你创建GitHub仓库、生成Token令牌并配置CDN加速,解决个人或小型网站图片存储与加载性能问题。适合前端开发者、独立博主、开源项目维护者及需要低成本图片托管方案的CS/AI学习者阅读。" date: "2025-09-27" tags: - image-hosting diff --git a/content/docs/community/dev-tips/raspberry-guide.en.md b/content/docs/community/dev-tips/raspberry-guide.en.md index d8227b09..f38c9d29 100644 --- a/content/docs/community/dev-tips/raspberry-guide.en.md +++ b/content/docs/community/dev-tips/raspberry-guide.en.md @@ -1,5 +1,6 @@ --- title: Building a Minecraft Server on an Idle Raspberry Pi +description: "Set up a Raspberry Pi Minecraft server with FRP port forwarding using an idle Pi and a VPS—perfect for self-hosters and open-source enthusiasts." date: 2025-08-05T18:53:40.000Z tags: null docId: i0xmpskau105p83vq35wnxls diff --git a/content/docs/community/dev-tips/raspberry-guide.md b/content/docs/community/dev-tips/raspberry-guide.md index 05b4a8b4..dfc115f4 100644 --- a/content/docs/community/dev-tips/raspberry-guide.md +++ b/content/docs/community/dev-tips/raspberry-guide.md @@ -1,5 +1,6 @@ --- title: 用闲置树莓派搭建一个Minecraft服务器 +description: "用闲置树莓派搭建Minecraft服务器完整教程,涵盖FRP内网穿透配置、Java环境安装与Fabric服务端部署,适合有树莓派和VPS的玩家、想利用旧设备搭建联机服务器的CS/AI学习者及自建游戏社区的技术爱好者。" date: 2025-08-05T18:53:40.000Z tags: null docId: i0xmpskau105p83vq35wnxls diff --git a/content/docs/community/index.en.mdx b/content/docs/community/index.en.mdx new file mode 100644 index 00000000..a42be3c8 --- /dev/null +++ b/content/docs/community/index.en.mdx @@ -0,0 +1,20 @@ +--- +title: Community Shares +description: "The Community Shares section of Involution Hell (involutionhell.com) brings together real-world experience and technical insights from CS/AI and job-hunting, covering algorithm practice, system design, interview tips, and more. Perfect for CS students and developers preparing for big-tech interviews or seeking career breakthroughs — learn from genuine stories, avoid common pitfalls, and find your path forward." +date: "2025-09-18" +docId: sfzt30mtx0jsuv6esnpm3w8y +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +import { SectionIndex } from "@/app/components/docs/SectionIndex"; + +Welcome to the Community Shares section! Whether you are a tech enthusiast or someone who loves life, feel free to contribute! + +A small article can sometimes help a lost stranger find their way. + +> Please contact the original author for permission before reposting. Thank you! + + diff --git a/content/docs/community/index.mdx b/content/docs/community/index.mdx index f98de4e5..12bff33d 100644 --- a/content/docs/community/index.mdx +++ b/content/docs/community/index.mdx @@ -1,5 +1,6 @@ --- title: 群友分享 +description: "内卷地狱 involutionhell.com 群友分享板块汇集 CS/AI/求职领域实战经验与技术干货,涵盖算法刷题、系统设计、面试技巧等核心内容。适合正在备战大厂面试、寻求职业突破的计算机学生与开发者,从真实案例中获取避坑指南与成长路径。" date: "2025-09-18" docId: sfzt30mtx0jsuv6esnpm3w8y --- diff --git a/content/docs/community/language/pte-intro.en.md b/content/docs/community/language/pte-intro.en.md new file mode 100644 index 00000000..2df20a24 --- /dev/null +++ b/content/docs/community/language/pte-intro.en.md @@ -0,0 +1,66 @@ +--- +title: PTE Academic — Task Types and Question Counts +description: "An introduction to PTE Academic task types and question counts: a detailed breakdown of the Speaking, Writing, Reading, and Listening modules along with cross-scoring mechanisms, with a focus on high-priority question types such as WFD, RS, RA, DI, SGD, SWT, WE, FIB-D, and FIB-DD. Ideal for test-takers planning to study or migrate abroad, IELTS/TOEFL switchers hoping to score quickly, and PTE newcomers." +date: "2025-09-19" +tags: + - pte +docId: m37j6a24hb9mlrm0g6jfcxop +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +Many students are unfamiliar with the PTE exam due to a lack of information. In reality, for those looking to obtain a language score or pursue immigration, PTE (Pearson Test of English) is often easier to score highly on than IELTS or TOEFL. Countless test-takers have contributed memorized questions and summaries of high-frequency topics, so with a bit of luck it can feel like an open-book exam. However, unlike IELTS and TOEFL, PTE Academic has a large variety of task types and requires strong test-taking strategies. Students who score well on IELTS may still struggle with PTE if they underestimate the importance of practice and technique. Here is a simple introduction to the task types and cross-scoring system — more PTE tips will follow in future updates. Feel free to leave a comment if there is something specific you would like to see covered. + +**PTE task types and question counts at a glance:** + +**TL;DR** — The highest-priority PTE task types are: WFD, RS, RA, DI, SGD, SWT, WE, FIB-D, FIB-DD. Focusing on these alone (when time is limited) can still yield a solid score. + +## Speaking (36–44 minutes, all tasks timed together) + +| Module | Order | Priority | Task | Cross-scored With | Count | Time | +| -------- | ----- | -------- | -------------------------------- | -------------------- | ----- | ------------------ | +| Speaking | 1 | Medium | Read Aloud (RA) | Speaking | 6–7 | Combined 36–44 min | +| Speaking | 2 | High | Repeat Sentence (RS) | Speaking · Listening | 10–12 | | +| Speaking | 3 | High | Describe Image (DI) | Speaking | 5–6 | | +| Speaking | 4 | Medium | Re-tell Lecture (RL) | Speaking · Listening | 2–3 | | +| Speaking | 5 | Medium | Answer Short Question (ASQ) | Listening | 5–6 | | +| Speaking | 6 | High | Summarize Group Discussion (SGD) | Speaking · Listening | 2–3 | | +| Speaking | 7 | Medium | Response to a Situation (RTS) | Speaking | 2–3 | | + +--- + +## Writing (independently timed) + +| Module | Order | Priority | Task | Cross-scored With | Count | Time | +| ------- | ----- | -------- | ---------------------------- | ----------------- | ----- | --------------- | +| Writing | 8 | High | Summarize Written Text (SWT) | Writing · Reading | 2 | 10 min per task | +| Writing | 9 | High | Write Essay (WE) | Writing | 1 | 20 min | + +--- + +## Reading (29–30 minutes, all tasks timed together) + +| Module | Order | Priority | Task | Cross-scored With | Count | Time | +| ------- | ----- | -------- | ------------------------------------------ | ----------------- | ----- | ------------------ | +| Reading | 10 | High | Dropdown Fill in the Blanks (FIB-D) | Reading | 5–6 | Combined 29–30 min | +| Reading | 11 | Low | Multiple Choice – Multiple Answers (MCQ-M) | Reading | 2–3 | | +| Reading | 12 | Medium | Reorder Paragraph (RO) | Reading | 2–3 | | +| Reading | 13 | High | Drag and Drop Fill in the Blanks (FIB-DD) | Reading | 4–5 | | +| Reading | 14 | Low | Multiple Choice – Single Answer (MCQ-S) | Reading | 2–3 | | + +--- + +## Listening (20–33 minutes, all tasks timed together — time is very tight; move quickly through lower-value tasks to save time for the high-scoring ones) + +| Module | Order | Priority | Task | Cross-scored With | Count | Time | +| --------- | ----- | ------------ | ------------------------------- | ------------------- | ----- | ------------------ | +| Listening | 15 | High | Summarize Spoken Text (SST) | Listening · Writing | 1 | 10 min per task | +| Listening | 16 | Low | Listening MCQ-M | Listening | 2–3 | Combined 20–33 min | +| Listening | 17 | Medium | Fill in the Blanks (FIB-L) | Listening | 2–3 | | +| Listening | 18 | Low | Highlight Correct Summary (HCS) | Listening · Reading | 2–3 | | +| Listening | 19 | Low | Listening MCQ-S | Listening | 1–2 | | +| Listening | 20 | Low | Select Missing Words (SMW) | Listening | 2–3 | | +| Listening | 21 | Medium | Highlight Incorrect Words (HIW) | Listening · Reading | 2–3 | | +| Listening | 22 | Top Priority | Write from Dictation (WFD) | Listening · Writing | 3–4 | | diff --git a/content/docs/community/language/pte-intro.md b/content/docs/community/language/pte-intro.md index 712505b0..4be2d497 100644 --- a/content/docs/community/language/pte-intro.md +++ b/content/docs/community/language/pte-intro.md @@ -1,6 +1,6 @@ --- title: PTE-Academic题型与题量介绍 -description: PTE-Academic题型与题量介绍 +description: "PTE Academic题型与题量介绍:详解口语、写作、阅读、听力四大模块及交叉评分机制,重点覆盖WFD、RS、RA、DI等高优先级题型,适合计划留学或移民、希望快速提分的雅思/托福转考考生及PTE新手阅读。" date: "2025-09-19" tags: - pte diff --git a/content/docs/community/life/unsw-student-benefit.en.md b/content/docs/community/life/unsw-student-benefit.en.md new file mode 100644 index 00000000..09ca282b --- /dev/null +++ b/content/docs/community/life/unsw-student-benefit.en.md @@ -0,0 +1,73 @@ +--- +title: UNSW Tuition Recovery Plan — Hidden Benefits You Might Not Know About +description: "A comprehensive breakdown of hidden benefits at UNSW (University of New South Wales), covering the Apple Education Store with up to 12% discount and Back to Uni gifts, the Career Discovery Mentoring Program (9 weeks with one-on-one coaching and AHEGS certification), and the official internship and job portal with visa status filtering. Essential reading for current UNSW students, prospective international students, and job seekers looking to save money and accelerate their careers." +date: "2025-10-03" +tags: + - unsw + - university-benefits + - student-resources + - australia-study +docId: jgyg6bp0nceyrxirz5qw3zsv +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +Recently chatting with classmates, I discovered that our university offers a wealth of hidden benefits that many students are completely unaware of — not just career-related, but also academic. So today I'm here to close the information gap and compile a collection of these hidden campus perks. Feel free to add more in the comments! + +## Apple Education Store for Students + +UNSW students can purchase iPads, MacBooks, and other Apple products directly through the Apple Education Store at prices lower than retail — discounts of up to 12%. Around February each year, there is often a "Back to Uni" promotion that includes a free pair of AirPods or a $240 gift card. + +[Apple UNSW Education Store](https://www.apple.com/au_edu_800094/store) + +Tip: The UNSW-specific link is usually slightly cheaper than the generic education discount link, so make sure you're using the right one. + +## UNSW Career Discovery Mentoring Program + +The UNSW Career Discovery Mentoring Program runs for 9 weeks and includes: an initial training and goal-setting phase, online professional development courses, five hours of one-on-one mentoring (online or in person), and a final reflection to earn AHEGS (Australian Higher Education Graduation Statement) certification. + +This program is generally only open during Term 1 and Term 3 — check the official website regularly for application deadlines. I heard that over 700 students applied in the cohort I joined, and some unfortunately did not get matched with a mentor, so take your application materials seriously! + +[Program details](https://www.unsw.edu.au/employability/discover/unsw-career-discovery-mentoring-program) + +The program features many outstanding mentors, including people from MIT — they not only share industry knowledge but some even offer internal referrals. Quite a few students have landed internship recommendations through this program, so it's a huge career booster. + +## Internships & Job Portal + +UNSW's official employment platform lists a wide range of internship, part-time, and full-time positions across computer science, engineering, finance, marketing, research, and more. You can filter opportunities by visa status. Many students previously had no idea why they were getting rejected instantly — often it was simply a visa eligibility mismatch. Using the visa filter, you can find companies that accept Student Visas and 485 Graduate Work Stream visas, which can significantly improve your application success rate. + +[Internship and job opportunities portal](https://unswconnect.unsw.edu.au/careers?disciplines=computer-science&disciplines=engineering-software&job_type=internships&work_rights=au-australian-working-visa&work_rights=au-australian-student-visa&work_rights=au-australian-skilled-migration-visa-485&work_rights=au-australian-bridging-visa) + +Many large companies and well-known firms post their job listings on this platform first. + +## UNSW On-Campus Jobs + +In addition to external internships and collaborative programs, UNSW itself recruits student assistants, research assistants, administrative support staff, and other on-campus positions. These roles are typically flexible and easy to fit around a student's schedule. + +[UNSW on-campus job listings](https://external-careers.jobs.unsw.edu.au/cw/en/listing/) + +Many students have not only earned income through on-campus roles but also built valuable work experience and formed close connections with academic departments and research teams. + +## Study Exchange Opportunities + +UNSW's exchange program is remarkably well-resourced, with partner institutions including ETH Zurich, the University of Pennsylvania's Wharton School, and dozens of top universities across Europe, Asia, and North America. + +[Search partner institutions](https://www.unsw.edu.au/student/opportunities/overseas-study/search-exchange-partners) + +Exchange programs let you earn credits, experience a different culture, and make international friends. One senior student who went to Wharton mentioned that through the exchange program, you only pay UNSW tuition rates — not the sky-high American tuition fees. That alone can save you thousands of dollars! + +## Other Student Benefits + +- **O-Week freebies**: New students receive a free hoodie and various club perks during Orientation Week. + +- **UNSW Fitness & Aquatic Centre discount**: The gym and pool are priced well below commercial rates. The popular UNSW swimming lessons cost just $75 for a full term — don't miss out! + +- **Arc Student Membership**: Enjoy free access to club events, a Welcome Pack, and discounts on various activities. Check Arc Sports for things like "Global Sports" — I've seen posts about activities like kayaking available for as low as $16.50, down from the original $95 price, though spots are limited so keep an eye out. + +- **Free counselling**: Book mental health counselling in Mandarin or English — covered by student insurance. + +- **UNSW Library**: Access to extensive electronic databases and free borrowing services. + +- **Career development workshops**: Resume reviews, mock interviews, and industry guest speaker events. diff --git a/content/docs/community/life/unsw-student-benefit.md b/content/docs/community/life/unsw-student-benefit.md index 94f3d8aa..5e6fdff7 100644 --- a/content/docs/community/life/unsw-student-benefit.md +++ b/content/docs/community/life/unsw-student-benefit.md @@ -1,6 +1,6 @@ --- title: UNSW学费回收计划-那些你还不知道的隐藏福利 -description: "" +description: "UNSW学费回收计划隐藏福利全解析,涵盖Apple教育商店最高12%折扣及返校季赠礼、职业导师计划(9周含一对一辅导与AHEGS认证)、官方实习就业平台支持签证筛选。适合UNSW在读生、准留学生及求职者了解省钱与职业发展资源。" date: "2025-10-03" tags: - unsw diff --git a/content/docs/community/mental-health/burnout-guide.en.mdx b/content/docs/community/mental-health/burnout-guide.en.mdx new file mode 100644 index 00000000..16bc0137 --- /dev/null +++ b/content/docs/community/mental-health/burnout-guide.en.mdx @@ -0,0 +1,81 @@ +--- +title: Programmer's Burnout Recovery Guide +description: "A burnout recovery guide for programmers: unpacks the chronic psychological state caused by prolonged stress and emotional exhaustion, covering triggers such as excessive conscientiousness, overwork, and workplace gaslighting (PUA), along with three core principles for recovery. Essential reading for programmers and job seekers experiencing insomnia, brain fog, or self-doubt under sustained high-pressure conditions." +date: "2025-01-27" +tags: + - burnout + - mental-health + - programmer +docId: q8d1j9bii2ve2p7pp4xtok79 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +> This article was compiled by YBJ0000 (https://github.com/YBJ0000) for internal community learning and sharing purposes only. + +--- + +## What Is Burnout? + +**ChatGPT's answer:** +Burnout is not simply "being tired" or "not wanting to work." It is **a chronic psychological state caused by the accumulation of prolonged stress and emotional exhaustion**. + +**Common symptoms:** + +- Dreading going to work; feeling oppressed the moment you step into the office +- Needing significant mental preparation before doing anything +- Saying things like "I want to die" casually + +> When people say "I want to die," they usually don't mean it literally. What they really mean is: I want to stop — no work notifications, sleep until I naturally wake up, eat good food, watch something light, have someone close by... just rest properly. + +--- + +## Why Does Burnout Happen? + +- Excessive sense of responsibility — wanting to do everything perfectly +- **Overwork**: internalizing external pressure as your own problem +- Susceptibility to **workplace gaslighting (PUA)** — constantly doubting whether you are good enough + +--- + +## Three Principles for Recovery + +1. **Your physical health comes first** + Insomnia, brain fog, nervous exhaustion → rest first → seek professional psychological intervention if symptoms become severe + + > Take PTO / FMLA + +2. **You have not done anything wrong** + - Boss micromanaging? Performance not where they want it? No visible growth? → **They are gaslighting you!** + - Tell yourself: _"You have already done well enough"_ × 3 + +3. **Do not quit impulsively** + - Think carefully if visa or immigration status is involved + - If financially viable → treat the job like a countdown timer collecting a paycheck + - Try to find your next role while still employed + +--- + +## What I Did After Burnout + +- **Engage with people!** I love my friends 🫂 +- Find a focus outside of work: + - Sudoku / vlogging / pets / exercise + - Even in a 996 grind, carve out a small hobby for yourself +- Therapist & company resources: improve sleep quality, sensory grounding exercises +- The "20 minutes in the park" method +- Dating: no personal experience here — proceed with caution + +--- + +## Final Thoughts + +- Burnout is a universal problem for working people everywhere +- Remember: **health > work > money** +- Wishing everyone happiness every day ☀️ + +--- + +> 📝 Original video source: [Bilibili - 璇璇想吃西瓜](https://www.bilibili.com/video/BV1jjHmzYEhV) diff --git a/content/docs/community/mental-health/burnout-guide.mdx b/content/docs/community/mental-health/burnout-guide.mdx index 036e0040..cb8af9d2 100644 --- a/content/docs/community/mental-health/burnout-guide.mdx +++ b/content/docs/community/mental-health/burnout-guide.mdx @@ -1,6 +1,6 @@ --- title: 程序员 Burnout 自救指南 -description: 转载自 B站 up主「璇璇想吃西瓜」,整理为社群分享版。 +description: "程序员 Burnout 自救指南:解析长期压力与情绪消耗导致的慢性心理状态,涵盖责任心过强、Overwork、PUA 等诱因及自救三原则。适合长期高压工作、出现失眠脑雾或怀疑自我的程序员与求职者阅读。" date: "2025-01-27" tags: - burnout diff --git a/content/docs/community/mental-health/index.en.mdx b/content/docs/community/mental-health/index.en.mdx new file mode 100644 index 00000000..e978f95e --- /dev/null +++ b/content/docs/community/mental-health/index.en.mdx @@ -0,0 +1,12 @@ +--- +title: Mental Health +description: "The Mental Health section of Involution Hell's documentation site focuses on psychological well-being under the high-pressure environments of CS/AI job seeking, covering anxiety management, burnout recovery, effective rest strategies, and mindfulness training. Highly recommended for programmers, AI practitioners, and CS students experiencing the grind of job hunting, 996 work culture, or intense academic pressure." +date: "2025-09-18" +docId: rxyvvumcvfl2oh3hky8urkfn +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +Welcome to the Mental Health section! diff --git a/content/docs/community/mental-health/index.mdx b/content/docs/community/mental-health/index.mdx index 9a8a5bc8..05d03e37 100644 --- a/content/docs/community/mental-health/index.mdx +++ b/content/docs/community/mental-health/index.mdx @@ -1,5 +1,6 @@ --- title: 心理健康 +description: "内卷地狱技术文档心理健康板块,聚焦CS/AI求职高压环境下的心理调适与情绪管理,涵盖焦虑缓解、职业倦怠应对、高效休息法及正念训练等关键技术点。适合正在经历求职内卷、面临996或高强度学习压力的程序员、AI从业者及计算机专业学生阅读。" date: "2025-09-18" docId: rxyvvumcvfl2oh3hky8urkfn --- diff --git a/content/docs/community/papers/leworldmodel.md b/content/docs/community/papers/leworldmodel.md index 7aa0bab4..73e96d31 100644 --- a/content/docs/community/papers/leworldmodel.md +++ b/content/docs/community/papers/leworldmodel.md @@ -1,6 +1,6 @@ --- title: LeWorldModel -description: 从像素端到端稳定训练的联合嵌入预测架构 +description: "LeWorldModel(LeWM)提出仅用两项损失函数(下一嵌入预测损失+高斯正则项)即可从原始像素端到端稳定训练联合嵌入预测架构(JEPA),将可调超参数从六个降至一个。1500万参数模型在单GPU上数小时完成训练,规划速度比基础模型世界模型快48倍,在2D/3D控制任务中保持竞争力。适合研究世界模型、隐空间表征及高效强化学习的AI/CS从业者与求职者。" date: "2026-04-08" tags: - world-models diff --git a/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.en.md b/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.en.md index 4bf9f221..5b0198d7 100644 --- a/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.en.md +++ b/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.en.md @@ -1,6 +1,6 @@ --- title: Prompt Repetition Improves Non-Reasoning LLMs -description: 复读机或可提高大模型能力 +description: "Learn how repeating input prompts boosts accuracy for non-reasoning LLMs like GPT, Gemini, and Claude without extra latency—ideal for AI engineers and researchers." date: "2026-03-05" tags: - AI diff --git a/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.md b/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.md index 9030b5c3..5d439471 100644 --- a/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.md +++ b/content/docs/community/papers/prompt-repetition-improves-non-reasoning-llms.md @@ -1,6 +1,6 @@ --- title: Prompt Repetition Improves Non-Reasoning LLMs -description: 复读机或可提高大模型能力 +description: "内卷地狱技术文档:Prompt Repetition Improves Non-Reasoning LLMs 探讨通过重复输入提示词提升主流模型(Gemini、GPT、Claude、DeepSeek)表现的方法,无需推理模式、不增加生成 token 或延迟。适合 AI 研究者、大模型应用开发者及求职者阅读。" date: "2026-03-05" tags: - AI diff --git a/content/docs/community/tools/index.en.md b/content/docs/community/tools/index.en.md new file mode 100644 index 00000000..5e0cd80f --- /dev/null +++ b/content/docs/community/tools/index.en.md @@ -0,0 +1,23 @@ +--- +title: Free AI Productivity Tools with Your Student Email +description: "A series on AI productivity tools available for free with a student email, featuring in-depth usage tips for Perplexity Comet, Cursor, and V0.dev — covering AI-powered search, code generation, and frontend development. Ideal for current students, job-seeking developers, and CS/AI learners who want to maximize free resources and boost their productivity." +date: "2025-10-03" +tags: + - edu-email + - ai-tools + - productivity +docId: mgb41edhi9cz1kxzae074an0 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +Student emails unlock a surprising number of free AI products. +Over the past couple of years, riding on free trials, a handful of AI tools have genuinely worked their way into my daily workflow and made a real dent in my productivity. +So I decided to start a series sharing these AI products and my experience using them — to help everyone claw back the cost of tuition. + +At the moment I can only think of 3 products worth covering; anything I can't recall probably isn't useful enough to mention. +Ranked by how often I use them: Perplexity Comet, Cursor, V0.dev. + +Once I've written about these three, I'll likely expand beyond student freebies and share other free/paid tools that have genuinely helped me: Gemini CLI, Codex, and more. diff --git a/content/docs/community/tools/index.md b/content/docs/community/tools/index.md index 6537bb50..0479794b 100644 --- a/content/docs/community/tools/index.md +++ b/content/docs/community/tools/index.md @@ -1,6 +1,6 @@ --- title: 学生邮箱能免费领的AI提效工具系列 -description: "" +description: "学生邮箱免费领取的AI提效工具系列,详解Perplexity Comet、Cursor、V0.dev三款产品的高频使用技巧,覆盖AI搜索、代码生成与前端开发场景,适合在校学生、求职开发者及想用免费资源提升效率的CS/AI学习者。" date: "2025-10-03" tags: - edu-email diff --git a/content/docs/community/tools/perplexity-comet.en.md b/content/docs/community/tools/perplexity-comet.en.md index 4f104631..69aeddb4 100644 --- a/content/docs/community/tools/perplexity-comet.en.md +++ b/content/docs/community/tools/perplexity-comet.en.md @@ -1,6 +1,6 @@ --- title: "Perplexity Comet: The AI Browser That Acts Like a Personal Assistant" -description: "" +description: "Get a free year of Perplexity Pro with Comet, an AI browser acting as a personal assistant for students and developers seeking deep research and task automation." date: "2025-10-03" tags: - perlexity diff --git a/content/docs/community/tools/perplexity-comet.md b/content/docs/community/tools/perplexity-comet.md index 363b88a5..904d27b6 100644 --- a/content/docs/community/tools/perplexity-comet.md +++ b/content/docs/community/tools/perplexity-comet.md @@ -1,6 +1,6 @@ --- title: Perplexity Comet 浏览器:能当私人管家的自动化浏览器 -description: "" +description: "Perplexity Comet 浏览器深度解析:一款能自动操作浏览器、整合邮件与日程的AI个人管家。核心技术点包括后台自动访问页面执行任务(如查邮件、查课程成绩)和前台实时自动化操作(如购物下单)。适合AI学习者、效率工具爱好者及希望用AI替代重复性工作的学生与开发者阅读。" date: "2025-10-03" tags: - perlexity diff --git a/content/docs/community/tools/swanlab.en.mdx b/content/docs/community/tools/swanlab.en.mdx index cdd4e7fb..ce5dd858 100644 --- a/content/docs/community/tools/swanlab.en.mdx +++ b/content/docs/community/tools/swanlab.en.mdx @@ -1,6 +1,6 @@ --- title: SwanLab Quick Start Guide -description: "" +description: "Track ML experiments with SwanLab: create an account, get an API key, and log results. A quick start for AI researchers and devs tired of messy tracking." date: "2025-09-23" tags: - ml-experiment-tracking diff --git a/content/docs/community/tools/swanlab.mdx b/content/docs/community/tools/swanlab.mdx index a163b9c8..c60c2034 100644 --- a/content/docs/community/tools/swanlab.mdx +++ b/content/docs/community/tools/swanlab.mdx @@ -1,6 +1,6 @@ --- title: swanlab快速上手指南 -description: "" +description: "SwanLab快速上手指南:教你用Python库与API Key完成实验追踪与可视化,解决AI/CS科研中实验记录混乱、结果难对比的问题。适合深度学习、机器学习研究者及求职者快速搭建实验pipeline。" date: "2025-09-23" tags: - ml-experiment-tracking diff --git a/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.en.md b/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.en.md index f82eda7f..10389e6d 100644 --- a/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.en.md +++ b/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.en.md @@ -1,6 +1,6 @@ --- title: Introduction of Multi-Agent Systems (For Any Task You Want) -description: "" +description: "Learn how Multi-Agent Systems (MAS) enable autonomous agents to cooperate and compete for emergent group intelligence, ideal for AI engineers and developers exploring distributed coordination." date: "2025-09-29" tags: - multi-agent-systems diff --git a/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.md b/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.md index 3b8a7639..120ae64a 100644 --- a/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.md +++ b/content/docs/learn/ai/Introduction-of-Multi-agents-system/introduction_of_multi-agents_system.md @@ -1,6 +1,6 @@ --- title: Introduction of Multi-agents system(In any task you want) -description: "" +description: "多智能体系统(MAS)入门:多个自治智能体在共享环境中交互、协作或竞争,产生单个智能体无法完成的涌现行为。关键技术点包括智能体的感知-决策-行动循环与环境类型(完全/部分可观测、静态/动态等)。适合AI学习者、系统设计工程师及求职者快速掌握群体协作与分布式问题解决思路。" date: "2025-09-29" tags: - multi-agent-systems diff --git a/content/docs/learn/ai/MoE/MOE-intro.md b/content/docs/learn/ai/MoE/MOE-intro.md index 46289199..2a150822 100644 --- a/content/docs/learn/ai/MoE/MOE-intro.md +++ b/content/docs/learn/ai/MoE/MOE-intro.md @@ -1,6 +1,6 @@ --- title: MOE 浅谈 -description: "混合专家(Mixture of Experts, MoE)架构的简要介绍" +description: "混合专家(MoE)架构详解:如何通过门控机制与条件计算在不显著增加算力下扩展大模型参数规模。涵盖传统MoE替换FFN层原理、Dense与Sparse路由机制差异。适合AI研究者、大模型开发者及对高效模型架构感兴趣的求职者。" tags: - MoE - AI diff --git a/content/docs/learn/ai/MoE/moe-update.en.md b/content/docs/learn/ai/MoE/moe-update.en.md index 3c9a30c8..b0cbb86b 100644 --- a/content/docs/learn/ai/MoE/moe-update.en.md +++ b/content/docs/learn/ai/MoE/moe-update.en.md @@ -1,6 +1,6 @@ --- title: "Theory of MoE" -description: "" +description: "Learn MoE theory with asymptotic notation (Ω, Θ, O, o) and key assumptions for closed-form forgetting formulas—ideal for CS/AI learners." date: "2025-10-05" tags: - mixture-of-experts diff --git a/content/docs/learn/ai/MoE/moe-update.md b/content/docs/learn/ai/MoE/moe-update.md index 60ff96ff..7f2e3f61 100644 --- a/content/docs/learn/ai/MoE/moe-update.md +++ b/content/docs/learn/ai/MoE/moe-update.md @@ -1,6 +1,6 @@ --- title: "Theory of MoE" -description: "" +description: "MoE(混合专家模型)理论详解:从基础公式定义出发,涵盖O/Ω/Θ/o渐近符号与线性模型简化假设,并解析task-wised路由方法及含噪声数据集的生成规则。适合希望理解MoE数学原理、闭式遗忘公式推导及路由机制的AI研究者与算法工程师。" date: "2025-10-05" tags: - mixture-of-experts diff --git a/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.en.mdx b/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.en.mdx index 6b0f8480..c2dc3149 100644 --- a/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.en.mdx +++ b/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.en.mdx @@ -1,6 +1,6 @@ --- title: Essential Reading for Getting Started with Code Translation -description: "" +description: "Discover foundational papers on code translation using LLMs, including executable representations, compiler feedback, and RL—ideal for AI/CS learners." date: "2025-09-19" tags: - code-translation diff --git a/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.mdx b/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.mdx index 6b1ddbca..eba52369 100644 --- a/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.mdx +++ b/content/docs/learn/ai/Multi-agents-system-on-Code-Translation/code-translation-intro.mdx @@ -1,6 +1,6 @@ --- title: Code translation入门推荐必读 -description: "" +description: "内卷地狱技术文档页详解代码翻译入门,涵盖ExeCoder可执行性表征、仓库级组合翻译等前沿方法,适合CS/AI学习者、求职者及LLM应用开发者快速掌握论文精要与实践路径。" date: "2025-09-19" tags: - code-translation diff --git a/content/docs/learn/ai/agents-todo/agent-ecosystem.en.mdx b/content/docs/learn/ai/agents-todo/agent-ecosystem.en.mdx index 0d7e635b..9646bccd 100644 --- a/content/docs/learn/ai/agents-todo/agent-ecosystem.en.mdx +++ b/content/docs/learn/ai/agents-todo/agent-ecosystem.en.mdx @@ -1,6 +1,6 @@ --- title: Agent -description: "LLM Agents: CS294/194-196 course, ReAct, FireAct, and more" +description: "Explore LLM agents: OpenHands for code/shell/web automation, Kimi-Researcher for RL-driven research, and OpenAI Deep Research—for developers & AI learners." status: todo docId: ue27z7z95yzw3lhhfj7nit1c lang: en diff --git a/content/docs/learn/ai/agents-todo/agent-ecosystem.mdx b/content/docs/learn/ai/agents-todo/agent-ecosystem.mdx index 4b261cf5..475c0a08 100644 --- a/content/docs/learn/ai/agents-todo/agent-ecosystem.mdx +++ b/content/docs/learn/ai/agents-todo/agent-ecosystem.mdx @@ -1,6 +1,6 @@ --- title: Agent -description: 大语言模型智能体:CS294/194-196课程、ReAct、FireAct等 +description: "LLM 智能体(Agent)技术框架与课程聚合页,涵盖 OpenHands 开源自动化平台、Kimi-Researcher 强化学习科研 Agent、OpenAI Deep Research 多步互联网研究模式及 KAG 知识图谱增强检索框架。适合 AI 开发者、科研人员及求职者系统学习 Agent 工具链与前沿实践。" status: todo docId: ue27z7z95yzw3lhhfj7nit1c --- diff --git a/content/docs/learn/ai/agents-todo/cs294-194-196/index.en.mdx b/content/docs/learn/ai/agents-todo/cs294-194-196/index.en.mdx index 0d89429c..e9324da0 100644 --- a/content/docs/learn/ai/agents-todo/cs294-194-196/index.en.mdx +++ b/content/docs/learn/ai/agents-todo/cs294-194-196/index.en.mdx @@ -1,6 +1,6 @@ --- title: CS294/194-196 Large Language Model Agents -description: Course materials for CS294/194-196 +description: "Learn about LLM agents from UC Berkeley's CS294/194-196 course: theory, practice, and systematic design for AI researchers and developers." docId: eo5rwumxkh7twfdvlp5po9rc lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/agents-todo/cs294-194-196/index.mdx b/content/docs/learn/ai/agents-todo/cs294-194-196/index.mdx index 61199cd4..9aa0e4cd 100644 --- a/content/docs/learn/ai/agents-todo/cs294-194-196/index.mdx +++ b/content/docs/learn/ai/agents-todo/cs294-194-196/index.mdx @@ -1,6 +1,6 @@ --- title: CS294/194-196 Large Language Model Agents -description: CS294/194-196 课程相关资料 +description: "UC Berkeley CS294/194-196 Large Language Model Agents 课程系统性讲解 LLM 智能体理论与实战,涵盖智能体架构设计、工具调用与多智能体协作。适合希望深入掌握大模型智能体开发、研究前沿 Agent 框架的 AI 研究者、算法工程师及高年级计算机学生。" docId: eo5rwumxkh7twfdvlp5po9rc --- diff --git a/content/docs/learn/ai/ai-math-basics/calculus-optimization/index.mdx b/content/docs/learn/ai/ai-math-basics/calculus-optimization/index.mdx index 86451de0..eeaad63c 100644 --- a/content/docs/learn/ai/ai-math-basics/calculus-optimization/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/calculus-optimization/index.mdx @@ -1,6 +1,6 @@ --- title: 微积分与优化 (Calculus & Optimization) -description: 微积分与优化核心概念及其在大模型中的应用 +description: "内卷地狱技术文档:微积分与优化核心概念,涵盖导数、梯度、链式法则、泰勒展开、拉格朗日乘子法与凸优化。详解反向传播中梯度计算、模型训练中SGD/Adam/RMSProp等优化器原理及激活函数导数特性。适合AI/CS求职者、深度学习入门者及算法工程师系统复习数学基础。" date: "2024-01-12" tags: - calculus diff --git a/content/docs/learn/ai/ai-math-basics/information-theory/index.mdx b/content/docs/learn/ai/ai-math-basics/information-theory/index.mdx index e16485e4..94f4dbeb 100644 --- a/content/docs/learn/ai/ai-math-basics/information-theory/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/information-theory/index.mdx @@ -1,6 +1,6 @@ --- title: 信息论 (Information Theory) -description: 信息论核心概念及其在大模型中的应用 +description: "信息论核心概念详解:信息量、熵、联合熵、条件熵、互信息、交叉熵与KL散度。深入解析交叉熵损失在神经网络训练、softmax注意力机制中的概率分布应用,以及强化学习中策略梯度的熵正则项与TRPO/PPO算法的KL散度约束。适合AI/CS求职者、大模型开发与算法工程师系统复习。" date: "2024-01-13" tags: - information-theory diff --git a/content/docs/learn/ai/ai-math-basics/linear-algebra/index.mdx b/content/docs/learn/ai/ai-math-basics/linear-algebra/index.mdx index 8bdeab93..868a5fc1 100644 --- a/content/docs/learn/ai/ai-math-basics/linear-algebra/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/linear-algebra/index.mdx @@ -1,6 +1,6 @@ --- title: 线性代数 (Linear Algebra) -description: 线性代数核心概念及其在大模型中的应用 +description: "线性代数核心概念:向量、矩阵、张量、特征值与特征向量、SVD奇异值分解及PCA主成分分析。深入解析大模型应用中的Embedding嵌入、Attention注意力机制QKV矩阵点积运算、Transformer架构矩阵运算与残差连接。适合AI算法工程师、大模型开发者及求职备考者阅读。" date: "2024-01-10" tags: - linear-algebra diff --git a/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.en.mdx b/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.en.mdx index cac27ae8..b00e6645 100644 --- a/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.en.mdx +++ b/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.en.mdx @@ -1,6 +1,6 @@ --- title: References -description: Linear algebra reference materials. +description: "Explore curated references for linear algebra and calculus, including immersive texts, geometric PDFs, and 3Blue1Brown’s visual video series—ideal for CS/AI learners building intuition." date: "2024-01-10" tags: - linear-algebra diff --git a/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.mdx b/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.mdx index d38e6d1a..f43fe8ea 100644 --- a/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/linear-algebra/resources/index.mdx @@ -1,6 +1,6 @@ --- title: 参考资料 -description: 线性代数参考资料。 +description: "内卷地狱技术文档页汇总线性代数核心学习资源:沉浸式线性代数互动教程、3Blue1Brown《线性代数的本质》系列视频与《线性代数的几何意义》PDF,侧重几何直观与可视化理解。适合CS/AI求职者、考研学生及希望夯实数学基础的开发者。" date: "2024-01-10" tags: - linear-algebra diff --git a/content/docs/learn/ai/ai-math-basics/math-foundations.mdx b/content/docs/learn/ai/ai-math-basics/math-foundations.mdx index d21d8dc8..2d95af7a 100644 --- a/content/docs/learn/ai/ai-math-basics/math-foundations.mdx +++ b/content/docs/learn/ai/ai-math-basics/math-foundations.mdx @@ -1,6 +1,6 @@ --- title: AI 数学基础 -description: AI相关数学基础知识:线性代数、概率统计、微积分优化、信息论、数值分析 +description: "AI 数学基础:深度学习与大模型开发必备的线性代数与概率论知识。涵盖向量、矩阵、张量、SVD、PCA等核心概念,以及Attention机制、QKV矩阵运算、Embedding、交叉熵损失、采样生成等大模型应用。适合AI工程师、算法研究者及求职者系统夯实数学功底。" date: "2025-01-27" tags: - mathematics diff --git a/content/docs/learn/ai/ai-math-basics/math_books.en.md b/content/docs/learn/ai/ai-math-basics/math_books.en.md index 8b50e4f9..7b33c633 100644 --- a/content/docs/learn/ai/ai-math-basics/math_books.en.md +++ b/content/docs/learn/ai/ai-math-basics/math_books.en.md @@ -1,6 +1,6 @@ --- title: Recommended Books on Mathematics and Data Science -description: "" +description: "Discover top math & data science books for all levels—from ML beginners to advanced researchers—covering probability, statistics, and foundations." date: "2025-10-06" tags: - math-textbooks diff --git a/content/docs/learn/ai/ai-math-basics/math_books.md b/content/docs/learn/ai/ai-math-basics/math_books.md index 069620ad..02b66f39 100644 --- a/content/docs/learn/ai/ai-math-basics/math_books.md +++ b/content/docs/learn/ai/ai-math-basics/math_books.md @@ -1,6 +1,6 @@ --- title: Recommended Books on Mathematics and Data Science -description: "" +description: "内卷地狱数学与数据科学推荐书单,覆盖机器学习、概率统计、贝叶斯推理、线性代数及数学史。关键技术点包括鸢尾花丛书系列(数学要素、矩阵力量、统计至简)及概率论沉思录。适合AI/CS求职者、数据科学初学者、研究者及数学爱好者。" date: "2025-10-06" tags: - math-textbooks diff --git a/content/docs/learn/ai/ai-math-basics/numerical-analysis/index.mdx b/content/docs/learn/ai/ai-math-basics/numerical-analysis/index.mdx index 47ec35b7..d8e3955b 100644 --- a/content/docs/learn/ai/ai-math-basics/numerical-analysis/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/numerical-analysis/index.mdx @@ -1,6 +1,6 @@ --- title: 数值分析 (Numerical Analysis) -description: 数值分析核心概念及其在大模型中的应用 +description: "数值分析课程核心讲解浮点数精度、数值稳定性与梯度裁剪技术,深入探讨大模型训练中BFloat16/FP16精度影响、优化器选择及防止梯度爆炸/消失策略。适合AI/CS求职者、大模型训练工程师及数值计算学习者。" date: "2024-01-14" tags: - numerical-analysis diff --git a/content/docs/learn/ai/ai-math-basics/probability-statistics/index.mdx b/content/docs/learn/ai/ai-math-basics/probability-statistics/index.mdx index 6e0852ff..b21c1fa7 100644 --- a/content/docs/learn/ai/ai-math-basics/probability-statistics/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/probability-statistics/index.mdx @@ -1,6 +1,6 @@ --- title: 概率论与数理统计 (Probability & Statistics) -description: 概率论与数理统计核心概念及其在大模型中的应用 +description: "概率论与数理统计核心知识:随机变量、概率分布(高斯、伯努利、多项式)、贝叶斯定理、最大似然估计(MLE)与最大后验估计(MAP)。大模型应用包括语言建模中的条件概率、交叉熵损失函数、Top-k/Top-p采样及RLHF策略优化。适合AI/CS求职者、大模型开发与算法工程师系统复习。" date: "2024-01-11" tags: - probability diff --git a/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.en.mdx b/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.en.mdx index d667ea60..f3e64d00 100644 --- a/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.en.mdx +++ b/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.en.mdx @@ -1,6 +1,6 @@ --- title: References -description: Probability and statistics reference materials. +description: "Explore curated references on involutionhell.com: key CS/AI papers, career resources, and open-source learning materials for developers and researchers." date: "2024-01-11" tags: - probability diff --git a/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.mdx b/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.mdx index dcca6bf3..5169d1e9 100644 --- a/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.mdx +++ b/content/docs/learn/ai/ai-math-basics/probability-statistics/resources/index.mdx @@ -1,6 +1,6 @@ --- title: 参考资料 -description: 概率论与数理统计参考资料。 +description: "内卷地狱 involutionhell.com 技术文档页汇总计算机科学、人工智能与求职面试的核心参考资料,涵盖算法、系统设计及机器学习面试高频题解与开源学习路径,适合正在备战大厂校招、社招或系统提升 CS/AI 基础能力的开发者与求职者阅读。" date: "2024-01-11" tags: - probability diff --git a/content/docs/learn/ai/compute-platforms/compute-platforms-handbook.mdx b/content/docs/learn/ai/compute-platforms/compute-platforms-handbook.mdx index ef0d9f93..40c6e6f9 100644 --- a/content/docs/learn/ai/compute-platforms/compute-platforms-handbook.mdx +++ b/content/docs/learn/ai/compute-platforms/compute-platforms-handbook.mdx @@ -1,6 +1,6 @@ --- title: 算力平台 -description: AI开发算力平台:AutoDL、InternStudio等云服务使用指南 +description: "AI模型训练与推理的算力平台选型指南:详解AutoDL(GPU云服务、PyCharm远程连接配置)与InternStudio(免费算力、SSH端口映射)两大主流平台。适合AI开发者、算法工程师、学生团队及个人研究者快速匹配计算资源。" date: "2025-01-27" tags: - compute-platforms diff --git a/content/docs/learn/ai/compute-platforms/model-compuational-resource-demand.md b/content/docs/learn/ai/compute-platforms/model-compuational-resource-demand.md index 1203a8a8..22d25da4 100644 --- a/content/docs/learn/ai/compute-platforms/model-compuational-resource-demand.md +++ b/content/docs/learn/ai/compute-platforms/model-compuational-resource-demand.md @@ -1,6 +1,6 @@ --- title: 算力需求指南 -description: 如何计算训练大模型所需显存大小 +description: "大模型多卡训练显存计算与优化指南,详解BF16/FP32参数存储、梯度与Adam优化器状态占用公式,适合准备大模型训练、面临显存瓶颈的AI工程师与求职者阅读。" date: "2025-09-20" tags: - compute-platforms diff --git a/content/docs/learn/ai/foundation-models/datasets/index.mdx b/content/docs/learn/ai/foundation-models/datasets/index.mdx index a78049ff..1395bb1c 100644 --- a/content/docs/learn/ai/foundation-models/datasets/index.mdx +++ b/content/docs/learn/ai/foundation-models/datasets/index.mdx @@ -1,6 +1,6 @@ --- title: 数据集构建 -description: 大模型数据集构建:数据来源、处理流程、质量控制 +description: "数据集构建是大模型训练的核心环节,涵盖Common Crawl、Wikipedia、GitHub代码与学术论文等多源数据采集,以及数据清洗、格式统一、去重处理和质量过滤等关键技术流程。适合AI工程师、NLP研究人员及大模型开发者阅读。" date: "2025-01-27" tags: - dataset-construction diff --git a/content/docs/learn/ai/foundation-models/deploy-infer/index.mdx b/content/docs/learn/ai/foundation-models/deploy-infer/index.mdx index 5c5ef80f..179fe4f6 100644 --- a/content/docs/learn/ai/foundation-models/deploy-infer/index.mdx +++ b/content/docs/learn/ai/foundation-models/deploy-infer/index.mdx @@ -1,6 +1,6 @@ --- title: 部署与推理 -description: 大模型部署与推理优化:KV Cache、Flash Attention、量化技术、推理框架 +description: "大模型部署与推理的核心技术详解,涵盖KV Cache缓存加速、Flash Attention内存高效注意力计算、INT8/INT4量化及并行推理策略。适合AI算法工程师、模型部署开发者和求职者系统学习推理优化与vLLM等框架实战。" date: "2025-01-27" tags: - model-deployment diff --git a/content/docs/learn/ai/foundation-models/evaluation/index.mdx b/content/docs/learn/ai/foundation-models/evaluation/index.mdx index 1b9417d3..091192d8 100644 --- a/content/docs/learn/ai/foundation-models/evaluation/index.mdx +++ b/content/docs/learn/ai/foundation-models/evaluation/index.mdx @@ -1,6 +1,6 @@ --- title: 模型评测 -description: 大模型评测体系:BenchMark、评测指标、中英文评测基准 +description: "模型评测详解大模型性能评估体系,涵盖MMLU多任务语言理解、GSM8K数学推理链等BenchMark基准,以及C-Eval、CMMLU中文评测方案,适合AI开发者、算法工程师及求职者系统掌握评测方法论。" date: "2025-01-27" tags: - model-evaluation diff --git a/content/docs/learn/ai/foundation-models/finetune/index.mdx b/content/docs/learn/ai/foundation-models/finetune/index.mdx index 154065e1..67030c06 100644 --- a/content/docs/learn/ai/foundation-models/finetune/index.mdx +++ b/content/docs/learn/ai/foundation-models/finetune/index.mdx @@ -1,6 +1,6 @@ --- title: 模型微调 -description: 大模型微调技术:LoRA、PEFT、微调框架等参数高效微调方法 +description: "模型微调技术详解:涵盖全参数微调与LoRA、AdaLoRA、Prefix Tuning等参数高效微调(PEFT)方法,解决灾难性遗忘与计算资源瓶颈。适合AI开发者、大模型应用工程师及求职者系统学习高效微调实践。" date: "2025-01-27" tags: - fine-tuning diff --git a/content/docs/learn/ai/foundation-models/foundation-models-lifecycle.mdx b/content/docs/learn/ai/foundation-models/foundation-models-lifecycle.mdx index ee0812ba..6d28b350 100644 --- a/content/docs/learn/ai/foundation-models/foundation-models-lifecycle.mdx +++ b/content/docs/learn/ai/foundation-models/foundation-models-lifecycle.mdx @@ -1,6 +1,6 @@ --- title: 基座大模型 -description: 基础模型的全生命周期:数据构建、训练、微调、部署与评测 +description: "基座大模型生命周期管理:从数据集构建、分布式训练、MoE混合专家模型到部署推理与评测。涵盖LoRA微调、KV Cache优化、Flash Attention加速等关键技术。适合AI开发者、算法工程师及求职者系统学习大模型技术栈。" date: "2025-01-27" tags: - foundation-models diff --git a/content/docs/learn/ai/foundation-models/qkv-interview/index.mdx b/content/docs/learn/ai/foundation-models/qkv-interview/index.mdx index 9192283f..731665b7 100644 --- a/content/docs/learn/ai/foundation-models/qkv-interview/index.mdx +++ b/content/docs/learn/ai/foundation-models/qkv-interview/index.mdx @@ -1,6 +1,6 @@ --- title: 经典面试QKV问题 -description: 深入解析Transformer中QKV机制和KV Cache的经典面试问题 +description: "Transformer中QKV机制是AI面试高频考点,本文深入解析KV可缓存而Q不可缓存的根本原因、WQ/WK/WV三个矩阵的功能分离设计以及多头注意力并行专门化原理,适合准备大模型岗位面试的求职者与NLP开发者系统复习。" date: "2025-01-27" tags: - interview-questions diff --git a/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.en.md b/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.en.md index 17c6aabf..c3ad95c8 100644 --- a/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.en.md +++ b/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.en.md @@ -1,6 +1,6 @@ --- title: A Quick Introduction to Context Engineering -description: "" +description: "Learn to optimize AI model inputs by managing context windows, reducing noise, and cutting token costs—for developers and prompt engineers on involutionhell.com." date: "2025-10-03" tags: - context-engineering diff --git a/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.md b/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.md index bad5519b..746588f6 100644 --- a/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.md +++ b/content/docs/learn/ai/foundation-models/rag/context-engineering-intro.md @@ -1,6 +1,6 @@ --- title: context engineering 快速了解 -description: "" +description: "Context engineering 快速了解:解决大模型上下文窗口有限、输入杂乱影响理解及高 token 成本问题。核心方法包括保存、选择与压缩 context,如 RAG 动态选择相关输入、Claude 自动压缩总结。适合 AI 开发者、Agent 构建者及希望优化模型输入效率的求职学习者。" date: "2025-10-03" tags: - context-engineering diff --git a/content/docs/learn/ai/foundation-models/rag/embedding.en.mdx b/content/docs/learn/ai/foundation-models/rag/embedding.en.mdx index 5107780f..dae2bcf6 100644 --- a/content/docs/learn/ai/foundation-models/rag/embedding.en.mdx +++ b/content/docs/learn/ai/foundation-models/rag/embedding.en.mdx @@ -1,6 +1,6 @@ --- title: A Beginner's Guide to Fine-Tuning Embedding Models -description: "" +description: "Learn to fine-tune embedding models for RAG systems: boost accuracy in specialized domains like finance or technical docs while reducing cost and hardware needs. For AI engineers and developers." date: "2025-09-22" tags: - RAG diff --git a/content/docs/learn/ai/foundation-models/rag/embedding.mdx b/content/docs/learn/ai/foundation-models/rag/embedding.mdx index 142b6fa1..c29e35db 100644 --- a/content/docs/learn/ai/foundation-models/rag/embedding.mdx +++ b/content/docs/learn/ai/foundation-models/rag/embedding.mdx @@ -1,6 +1,6 @@ --- title: 嵌入模型微调入门知识 -description: "" +description: "嵌入模型微调入门知识:详解为何通用大模型在金融合规、内部知识库等专业领域效果不如微调后的小模型,并介绍双LLM合成-评测链等近期创新点。适合希望掌握领域自适应嵌入模型微调方法、提升RAG系统检索与问答质量的AI工程师和开发者。" date: "2025-09-22" tags: - RAG diff --git a/content/docs/learn/ai/foundation-models/rag/rag.en.mdx b/content/docs/learn/ai/foundation-models/rag/rag.en.mdx index 17fd6378..7151f33a 100644 --- a/content/docs/learn/ai/foundation-models/rag/rag.en.mdx +++ b/content/docs/learn/ai/foundation-models/rag/rag.en.mdx @@ -1,6 +1,6 @@ --- title: RAG -description: "" +description: "Learn RAG (Retrieval-Augmented Generation) pipeline in under 10 minutes: chunking, embedding, retrieval, and LLM integration for domain-specific Q&A." date: "2025-09-19" tags: - rag-system diff --git a/content/docs/learn/ai/foundation-models/rag/rag.mdx b/content/docs/learn/ai/foundation-models/rag/rag.mdx index eda70a00..3d07fef3 100644 --- a/content/docs/learn/ai/foundation-models/rag/rag.mdx +++ b/content/docs/learn/ai/foundation-models/rag/rag.mdx @@ -1,6 +1,6 @@ --- title: RAG -description: "" +description: "内卷地狱 RAG 技术文档详解检索增强生成流程:从分片、Embedding 化到向量数据库召回与重排,10 分钟快速搭建 toy demo。适合想弄懂 RAG 本质的 AI 初学者、求职者及需要构建外部知识库的开发者。" date: "2025-09-19" tags: - rag-system diff --git a/content/docs/learn/ai/foundation-models/training/index.mdx b/content/docs/learn/ai/foundation-models/training/index.mdx index 4964c8c8..7e28b830 100644 --- a/content/docs/learn/ai/foundation-models/training/index.mdx +++ b/content/docs/learn/ai/foundation-models/training/index.mdx @@ -1,6 +1,6 @@ --- title: 模型训练 -description: 大模型训练技术:MoE、分布式训练、模型权重合并等 +description: "大模型训练技术文档详解训练流程、分布式并行策略与MoE架构,涵盖梯度累积、混合精度、3D并行及稀疏激活等关键技术,适合AI工程师、算法研究员及求职备考者系统学习。" date: "2025-01-27" tags: - model-training diff --git a/content/docs/learn/ai/generative-todo/generative-models-plan.mdx b/content/docs/learn/ai/generative-todo/generative-models-plan.mdx index d7d7769a..9caa571e 100644 --- a/content/docs/learn/ai/generative-todo/generative-models-plan.mdx +++ b/content/docs/learn/ai/generative-todo/generative-models-plan.mdx @@ -1,6 +1,6 @@ --- title: 生成模型 -description: 生成模型:Diffusion 等生成技术 +description: "内卷地狱技术文档页详解生成模型主题,聚焦扩散模型(Diffusion)等前沿生成技术原理与实现路径,适合正在备战CS/AI求职面试、希望系统掌握生成式模型核心知识点的学习者阅读。" status: todo docId: nor5ktairygnt4dorqbddo9n --- diff --git a/content/docs/learn/ai/index.en.mdx b/content/docs/learn/ai/index.en.mdx new file mode 100644 index 00000000..cec24d72 --- /dev/null +++ b/content/docs/learn/ai/index.en.mdx @@ -0,0 +1,32 @@ +--- +title: AI Knowledge Base +description: "The Involution Hell AI Knowledge Base aggregates high-quality learning resources covering mathematical foundations, large language models, reinforcement learning, multimodal models, and recommender systems. Ideal for CS/AI job seekers, research newcomers, and developers looking to systematically build their AI knowledge." +date: "2025-01-27" +tags: + - ai + - machine-learning + - deep-learning + - llm +docId: ix9azldhgm46j4i1xzgnd26r +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +This knowledge base aims to aggregate high-quality AI learning resources, reduce information fragmentation and duplication, and support collaborative maintenance and continuous updates. + +## Learning Paths + +The knowledge base is organized around the following structure: + +- AI Math Foundations: linear algebra, probability and statistics, calculus and optimization, information theory, numerical analysis +- Large Model Basics: deep learning, PyTorch, CUDA, Transformer, Embedding, introductory courses +- Reinforcement Learning: RL fundamentals, chain-of-thought (CoT), GRPO +- Foundation Models: datasets, training, fine-tuning, deployment, evaluation, model architectures +- Multimodal Large Models: LLaVA, QwenVL, ViT, MLLM +- Recommender Systems: learning paths, hands-on projects, paper resources +- Agents: LLM-based intelligent agents +- Generative Models: Diffusion Models +- Methodology: research guides, paper reading strategies +- Miscellaneous Tools: development tools, platform usage diff --git a/content/docs/learn/ai/index.mdx b/content/docs/learn/ai/index.mdx index 5c0e6f84..62b3f9b4 100644 --- a/content/docs/learn/ai/index.mdx +++ b/content/docs/learn/ai/index.mdx @@ -1,6 +1,6 @@ --- title: AI 知识库 -description: UNSW IT-AI内卷地狱 - AI 学习资源全面整理 +description: "内卷地狱 AI 知识库汇总高质量学习资源,覆盖数学基础、大模型、强化学习、多模态与推荐系统等关键技术点,适合 CS/AI 求职者、科研入门者及希望系统构建 AI 知识体系的开发者阅读。" date: "2025-01-27" tags: - ai diff --git a/content/docs/learn/ai/llm-basics/courses/index.mdx b/content/docs/learn/ai/llm-basics/courses/index.mdx index 47670da8..7132eb14 100644 --- a/content/docs/learn/ai/llm-basics/courses/index.mdx +++ b/content/docs/learn/ai/llm-basics/courses/index.mdx @@ -1,6 +1,6 @@ --- title: 大模型入门课程 -description: 深度学习与大模型相关的课程资料汇总。 +description: "大模型入门课程汇总斯坦福CS224N、CMU Advanced NLP、NanoGPT及CS336等经典资源,覆盖从NLP基础、Transformer架构到BPE分词器、Flash Attention、Scaling Law等关键技术点,适合希望系统学习大模型理论与从零动手实现的AI初学者和求职者。" docId: xboc8qj2128aivvt0goo1wow --- diff --git a/content/docs/learn/ai/llm-basics/cuda/index.mdx b/content/docs/learn/ai/llm-basics/cuda/index.mdx index a34f2d52..63e0f476 100644 --- a/content/docs/learn/ai/llm-basics/cuda/index.mdx +++ b/content/docs/learn/ai/llm-basics/cuda/index.mdx @@ -1,6 +1,6 @@ --- title: CUDA -description: CUDA 学习资料与大模型相关优化技术 +description: "内卷地狱 CUDA 技术文档页详解 GPU 并行计算与内存优化,涵盖 profiling 定位性能瓶颈及 FlashAttention、Ring Attention 等模型加速核心组件。适合希望掌握 Triton、Cutlass 等新一代高性能 GPU 编程框架的 CS/AI 求职者与进阶学习者。" date: "2024-01-17" tags: - cuda diff --git a/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.en.mdx b/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.en.mdx index ded59efc..d74c42ab 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.en.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.en.mdx @@ -1,6 +1,6 @@ --- title: Dive into Deep Learning (D2L) by Mu Li -description: Notes related to Dive into Deep Learning. +description: "Explore Dive into Deep Learning (D2L) by Mu Li: access official resources, PyTorch & PDF e-books, and study notes for AI learners." date: "2024-01-18" tags: - d2l diff --git a/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.mdx b/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.mdx index 1e456272..3f0acfd0 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/d2l/index.mdx @@ -1,6 +1,6 @@ --- title: 李沐动手学深度学习 -description: 《动手学深度学习》相关笔记。 +description: "李沐《动手学深度学习》技术文档页,系统梳理D2L官方资源、PyTorch版电子书及中文学习笔记。适合AI初学者、深度学习入门者及求职备考者,通过动手实践掌握核心算法与框架应用。" date: "2024-01-18" tags: - d2l diff --git a/content/docs/learn/ai/llm-basics/deep-learning/index.mdx b/content/docs/learn/ai/llm-basics/deep-learning/index.mdx index 11a4acb6..c4e54917 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/index.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/index.mdx @@ -1,6 +1,6 @@ --- title: 深度学习基础 -description: 深度学习基础知识:李沐动手学深度学习、NLP、机器学习资源 +description: "深度学习基础页系统梳理从线性回归到注意力机制的核心知识,提供李沐《动手学深度学习》官方教程、PyTorch与MXNet双版本代码实现及中文笔记资源,适合零基础入门者、AI求职者及希望系统巩固深度学习理论并动手实践的CS学习者。" date: "2025-01-27" tags: - deep-learning diff --git a/content/docs/learn/ai/llm-basics/deep-learning/misc/index.en.mdx b/content/docs/learn/ai/llm-basics/deep-learning/misc/index.en.mdx index c9e72aa0..7590d758 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/misc/index.en.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/misc/index.en.mdx @@ -1,6 +1,6 @@ --- title: Other Resources -description: Miscellaneous deep learning resources. +description: "Explore curated ML resources: the Pumpkin Book for deep math derivations, Li Hongyi’s beginner-friendly DL notes, and the Deep Learning Bible—ideal for CS/AI learners." docId: lodydcd211esraq1r55ze9ey lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/llm-basics/deep-learning/misc/index.mdx b/content/docs/learn/ai/llm-basics/deep-learning/misc/index.mdx index faef1a6e..f7196e1e 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/misc/index.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/misc/index.mdx @@ -1,6 +1,6 @@ --- title: 其他资料 -description: 深度学习杂项资料。 +description: "内卷地狱技术文档页汇总机器学习南瓜书(周志华《机器学习》公式推导解析)、李宏毅深度学习笔记(零基础友好)、花书及MIT深度学习教材等核心资源,适合希望深入理解算法数学原理的学习者、研究人员及自学编程的开发者。" docId: lodydcd211esraq1r55ze9ey --- diff --git a/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.en.mdx b/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.en.mdx index c2586dae..4e3bf27d 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.en.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.en.mdx @@ -1,6 +1,6 @@ --- title: NLP -description: Natural language processing fundamentals. +description: "Master NLP fundamentals with HuggingFace: Transformers, fine-tuning, BERT & GPT. For CS/AI learners building real-world text applications." docId: nrelvvfzq0gma7pqfx9fkfxt lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.mdx b/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.mdx index 510f704f..dae0a0fe 100644 --- a/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.mdx +++ b/content/docs/learn/ai/llm-basics/deep-learning/nlp/index.mdx @@ -1,6 +1,6 @@ --- title: NLP -description: 自然语言处理基础。 +description: "内卷地狱NLP基础页详解HuggingFace Transformers库使用、模型微调与部署,覆盖文本预处理、词向量、RNN/LSTM到Transformer/BERT/GPT系列架构,适合CS/AI求职者及NLP初学者系统学习经典与现代自然语言处理技术。" docId: nrelvvfzq0gma7pqfx9fkfxt --- diff --git a/content/docs/learn/ai/llm-basics/embeddings/index.en.mdx b/content/docs/learn/ai/llm-basics/embeddings/index.en.mdx index f50da57e..474c1a4e 100644 --- a/content/docs/learn/ai/llm-basics/embeddings/index.en.mdx +++ b/content/docs/learn/ai/llm-basics/embeddings/index.en.mdx @@ -1,6 +1,6 @@ --- title: Embedding Models -description: Resources on embeddings and vector representations. +description: "Learn how embedding models map discrete objects like words and images into continuous vectors for semantic similarity, retrieval, and clustering—ideal for AI/ML learners and engineers." date: "2024-01-15" tags: - embedding diff --git a/content/docs/learn/ai/llm-basics/embeddings/index.mdx b/content/docs/learn/ai/llm-basics/embeddings/index.mdx index 22ad9c15..42a6ba9b 100644 --- a/content/docs/learn/ai/llm-basics/embeddings/index.mdx +++ b/content/docs/learn/ai/llm-basics/embeddings/index.mdx @@ -1,6 +1,6 @@ --- title: Embedding模型 -description: Embedding/向量化相关资料。 +description: "Embedding模型将词语、句子、图片等离散对象映射为连续向量,实现语义保留与可计算性,是RAG检索增强生成与多模态融合的核心工具。适合AI学习者、NLP工程师及大模型应用开发者阅读。" date: "2024-01-15" tags: - embedding diff --git a/content/docs/learn/ai/llm-basics/embeddings/qwen3-embedding/index.mdx b/content/docs/learn/ai/llm-basics/embeddings/qwen3-embedding/index.mdx index b3fddb14..7860e730 100644 --- a/content/docs/learn/ai/llm-basics/embeddings/qwen3-embedding/index.mdx +++ b/content/docs/learn/ai/llm-basics/embeddings/qwen3-embedding/index.mdx @@ -1,6 +1,6 @@ --- title: Qwen3-embedding -description: Qwen3 Embedding 模型的关键点、深度解读与实战资料 +description: "Qwen3-Embedding 技术文档详解 SLERP 权重合并算法与 LoRA 微调实战,涵盖模型深度解读与高效微调方法。适合 NLP 工程师、AI 研究员及求职备考者学习前沿嵌入模型技术。" date: "2024-01-15" tags: - qwen3 diff --git a/content/docs/learn/ai/llm-basics/llm-foundations.mdx b/content/docs/learn/ai/llm-basics/llm-foundations.mdx index a4b36878..5a794271 100644 --- a/content/docs/learn/ai/llm-basics/llm-foundations.mdx +++ b/content/docs/learn/ai/llm-basics/llm-foundations.mdx @@ -1,6 +1,6 @@ --- title: 大模型基础 -description: 大模型基础知识体系:深度学习、PyTorch、CUDA、Transformer +description: "大模型基础页面系统梳理从深度学习理论到实际开发的完整知识体系,涵盖PyTorch框架、CUDA编程、Transformer架构与Embedding模型等关键技术点,适合AI初学者、进阶开发者及研究导向学习者系统规划学习路径。" date: "2025-01-27" tags: - llm-basics diff --git a/content/docs/learn/ai/llm-basics/pytorch/index.mdx b/content/docs/learn/ai/llm-basics/pytorch/index.mdx index 21be19a1..fcfda1d8 100644 --- a/content/docs/learn/ai/llm-basics/pytorch/index.mdx +++ b/content/docs/learn/ai/llm-basics/pytorch/index.mdx @@ -1,6 +1,6 @@ --- title: PyTorch -description: PyTorch深度学习框架:入门教程、张量操作、面试要点 +description: "PyTorch深度学习框架入门指南,涵盖张量操作、自动梯度、神经网络构建与训练循环设计等核心技术点。适合零基础学习者、AI研究者及大模型开发求职者,提供小土堆视频教程、官方中文文档、面试精华等资源,助你系统掌握PyTorch并应对求职面试。" date: "2025-01-27" tags: - pytorch diff --git a/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.en.mdx b/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.en.mdx index 428d2154..6903ae31 100644 --- a/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.en.mdx +++ b/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.en.mdx @@ -1,6 +1,6 @@ --- title: "AI by Hand: Build AI Models Manually" -description: Resources and introduction to the AI by Hand project +description: "Learn core AI model computations by hand—Transformer attention, matrix operations—with illustrated walkthroughs for learners seeking fundamental logic." date: "2024-01-16" tags: - ai-by-hand diff --git a/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.mdx b/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.mdx index a0d4e0f4..15851a50 100644 --- a/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.mdx +++ b/content/docs/learn/ai/llm-basics/transformer/ai-by-hand/index.mdx @@ -1,6 +1,6 @@ --- title: AI by Hand:手搓 AI 模型 -description: AI by Hand 项目资源与介绍 +description: "AI by Hand 手搓 AI 模型技术文档页,以图解与交互式展示从零拆解 Transformer 核心运算,手算 Attention 与矩阵机制,适合希望从基础逻辑层面深入理解大模型原理的 CS/AI 学习者和求职者。" date: "2024-01-16" tags: - ai-by-hand diff --git a/content/docs/learn/ai/llm-basics/transformer/index.mdx b/content/docs/learn/ai/llm-basics/transformer/index.mdx index 7b68727b..e3e388a7 100644 --- a/content/docs/learn/ai/llm-basics/transformer/index.mdx +++ b/content/docs/learn/ai/llm-basics/transformer/index.mdx @@ -1,6 +1,6 @@ --- title: Transformer -description: Transformer 架构与注意力机制相关资料 +description: "Transformer 核心论文与代码详解,涵盖 Self-Attention 的 QKV 计算、Scaled Dot-Product 与 Multi-Head Attention 原理,以及分词、位置编码、掩码、层归一化等关键技术点。适合 CS/AI 求职者、深度学习初学者及希望系统掌握 Transformer 架构的开发者阅读。" date: "2024-01-16" tags: - transformer diff --git a/content/docs/learn/ai/methodology/research-methodology.mdx b/content/docs/learn/ai/methodology/research-methodology.mdx index feac1a3d..1634a79b 100644 --- a/content/docs/learn/ai/methodology/research-methodology.mdx +++ b/content/docs/learn/ai/methodology/research-methodology.mdx @@ -1,6 +1,6 @@ --- title: 方法论学习 -description: 科研自救指南:研究方向、论文速读、代码复现、SCI投稿等方法论 +description: "科研方法论完整指南覆盖研究方向选择、文献调研、问题识别与技术趋势跟踪,详解大模型辅助论文速读与代码复现流程,适合CS/AI领域研究生、科研新手及求职者系统提升科研效率与论文产出能力。" date: "2025-01-27" tags: - methodology diff --git a/content/docs/learn/ai/misc-tools/learning-toolkit.mdx b/content/docs/learn/ai/misc-tools/learning-toolkit.mdx index 9e86e071..934d7715 100644 --- a/content/docs/learn/ai/misc-tools/learning-toolkit.mdx +++ b/content/docs/learn/ai/misc-tools/learning-toolkit.mdx @@ -1,6 +1,6 @@ --- title: 杂项工具 -description: AI开发与学习相关的实用工具集合 +description: "内卷地狱技术文档页汇总 AI 学习与开发中的杂项工具,涵盖 Zotero 文献管理与 PDF 标注、GitHub 镜像加速及 CSDN 资源获取方法,并介绍 Perplexity 智能搜索与 Connected Papers 论文关联可视化。适合 CS/AI 求职者、科研学生及开发者提升工具链效率。" date: "2025-09-19" tags: - tools diff --git a/content/docs/learn/ai/model-datasets-platforms/platform-and-datasets.mdx b/content/docs/learn/ai/model-datasets-platforms/platform-and-datasets.mdx index 4e32f8a8..d31bd8bb 100644 --- a/content/docs/learn/ai/model-datasets-platforms/platform-and-datasets.mdx +++ b/content/docs/learn/ai/model-datasets-platforms/platform-and-datasets.mdx @@ -1,6 +1,6 @@ --- title: 模型数据集平台 -description: 主流AI模型、数据集和开发平台汇总 +description: "模型数据集平台汇总主流AI开发平台与数据集资源,重点解析Hugging Face的模型库、Datasets库及Spaces在线演示功能,以及ModelScope魔搭社区的中文模型优势,同时涵盖Kaggle竞赛数据集与UCI经典数据集。适合AI开发者、机器学习学习者及求职备战者快速定位高质量模型与数据资源。" date: "2025-01-27" tags: - platforms diff --git a/content/docs/learn/ai/multimodal/RQVAE/index.en.mdx b/content/docs/learn/ai/multimodal/RQVAE/index.en.mdx index 6ba7cea2..7072f75a 100644 --- a/content/docs/learn/ai/multimodal/RQVAE/index.en.mdx +++ b/content/docs/learn/ai/multimodal/RQVAE/index.en.mdx @@ -1,6 +1,6 @@ --- title: RQ-VAE Study Notes -description: Notes and insights from studying RQ-VAE +description: "Learn RQ-VAE (Residual Quantization VAE) to overcome VQ-VAE's rate-distortion trade-off and codebook collapse—ideal for AI/ML engineers studying high-fidelity discrete latent representations." docId: pqplmwaj5o5aszydqo1drzrj lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/multimodal/RQVAE/index.mdx b/content/docs/learn/ai/multimodal/RQVAE/index.mdx index 8cd88386..a0162557 100644 --- a/content/docs/learn/ai/multimodal/RQVAE/index.mdx +++ b/content/docs/learn/ai/multimodal/RQVAE/index.mdx @@ -1,6 +1,6 @@ --- title: RQ-VAE学习笔记 -description: 学习RQ-VAE时的心得 +description: "RQ-VAE残差量化变分自动编码器学习笔记,详解其如何通过多级残差量化克服VQ-VAE码本过大与码本崩溃问题,实现高压缩率与高保真重建。适合研究图像生成、自回归模型及离散潜变量编码的AI学习者和求职者。" docId: pqplmwaj5o5aszydqo1drzrj --- diff --git a/content/docs/learn/ai/multimodal/VAE/index.en.mdx b/content/docs/learn/ai/multimodal/VAE/index.en.mdx index 3d7f373d..c2c4ff81 100644 --- a/content/docs/learn/ai/multimodal/VAE/index.en.mdx +++ b/content/docs/learn/ai/multimodal/VAE/index.en.mdx @@ -1,6 +1,6 @@ --- title: VAE Study Notes -description: Notes and insights from studying VAE +description: "Learn VAE fundamentals: how variational inference enables generative modeling by constraining latent space distributions, for AI learners studying deep generative models." docId: k6cgwcc28l9iap5s5oyjbjwo lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/multimodal/VAE/index.mdx b/content/docs/learn/ai/multimodal/VAE/index.mdx index 975bb7c4..56ba4faf 100644 --- a/content/docs/learn/ai/multimodal/VAE/index.mdx +++ b/content/docs/learn/ai/multimodal/VAE/index.mdx @@ -1,6 +1,6 @@ --- title: VAE学习笔记 -description: 学习VAE时的心得 +description: "VAE变分自编码器深度生成模型详解,涵盖编码器-解码器结构与潜在空间分布约束,对比传统自编码器在生成新样本上的局限,适合AI学习者、深度学习入门者及求职准备者系统掌握VAE原理。" docId: k6cgwcc28l9iap5s5oyjbjwo --- diff --git a/content/docs/learn/ai/multimodal/VQVAE/index.en.mdx b/content/docs/learn/ai/multimodal/VQVAE/index.en.mdx index ecbdecf6..25e2a2d0 100644 --- a/content/docs/learn/ai/multimodal/VQVAE/index.en.mdx +++ b/content/docs/learn/ai/multimodal/VQVAE/index.en.mdx @@ -1,6 +1,6 @@ --- title: VQ-VAE Study Notes -description: Notes and insights from studying VQ-VAE +description: "Learn VQ-VAE: how discrete codebooks prevent posterior collapse in VAEs, capturing discrete data features for AI/ML practitioners." docId: otfiks0uz3aue1bdvlyqmj3e lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/multimodal/VQVAE/index.mdx b/content/docs/learn/ai/multimodal/VQVAE/index.mdx index 692df048..f7bef9be 100644 --- a/content/docs/learn/ai/multimodal/VQVAE/index.mdx +++ b/content/docs/learn/ai/multimodal/VQVAE/index.mdx @@ -1,6 +1,6 @@ --- title: VQ-VAE学习笔记 -description: 学习VQ-VAE时的心得 +description: "VQ-VAE学习笔记:深入解析向量量化变分自编码器如何通过离散代码簿解决后验坍塌问题,提升生成质量。涵盖模型结构、编码器-解码器与代码簿工作机制,以及离散潜变量在图像、语音生成中的优势。适合正在学习生成模型、理解VAE变体及准备AI面试的研究生与求职者。" docId: otfiks0uz3aue1bdvlyqmj3e --- diff --git a/content/docs/learn/ai/multimodal/courses/index.en.mdx b/content/docs/learn/ai/multimodal/courses/index.en.mdx index 9f095280..20381e37 100644 --- a/content/docs/learn/ai/multimodal/courses/index.en.mdx +++ b/content/docs/learn/ai/multimodal/courses/index.en.mdx @@ -1,6 +1,6 @@ --- title: Multimodal Foundational Courses -description: Multimodal machine learning courses. +description: "Explore CMU's Multimodal Machine Learning course covering representation learning, alignment, and fusion. Ideal for CS/AI learners seeking systematic technical foundations." date: "2024-01-18" tags: - multimodal diff --git a/content/docs/learn/ai/multimodal/courses/index.mdx b/content/docs/learn/ai/multimodal/courses/index.mdx index 09400ecd..dc0ef64f 100644 --- a/content/docs/learn/ai/multimodal/courses/index.mdx +++ b/content/docs/learn/ai/multimodal/courses/index.mdx @@ -1,6 +1,6 @@ --- title: 多模态基础课程 -description: 多模态学习课程。 +description: "卡内基梅隆大学多模态机器学习课程详解,覆盖表示学习、对齐、融合与迁移等核心技术,适合AI研究者、计算机视觉及NLP方向学生、求职者系统掌握情感识别、对话系统与视频理解等前沿应用。" date: "2024-01-18" tags: - multimodal diff --git a/content/docs/learn/ai/multimodal/llava/index.mdx b/content/docs/learn/ai/multimodal/llava/index.mdx index 000f5f16..26e30f3f 100644 --- a/content/docs/learn/ai/multimodal/llava/index.mdx +++ b/content/docs/learn/ai/multimodal/llava/index.mdx @@ -1,6 +1,6 @@ --- title: LLaVA -description: LLaVA多模态大模型框架:架构解析、CLIP基础、论文精读、复现实践 +description: "LLaVA多模态大模型框架详解:视觉指令调优与跨模态对齐核心技术,涵盖CLIP双塔结构、视觉编码与语言生成机制。适合AI研究者、计算机视觉与NLP方向学生、大模型应用开发者阅读。" date: "2025-01-27" tags: - llava diff --git a/content/docs/learn/ai/multimodal/mllm/index.en.mdx b/content/docs/learn/ai/multimodal/mllm/index.en.mdx index 3c90a7ba..865154b7 100644 --- a/content/docs/learn/ai/multimodal/mllm/index.en.mdx +++ b/content/docs/learn/ai/multimodal/mllm/index.en.mdx @@ -1,6 +1,6 @@ --- title: MLLM — Multimodal Large Language Models -description: Resources on multimodal large language models (MLLMs) +description: "Explore MLLM research: visual token pruning for VLM acceleration, multimodal reasoning with scalable training, and explainability via token activation maps for AI/CS learners." docId: gc6tdzkkwxn5t90nw69fibl6 lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/multimodal/mllm/index.mdx b/content/docs/learn/ai/multimodal/mllm/index.mdx index 1a3307b8..bd0894e5 100644 --- a/content/docs/learn/ai/multimodal/mllm/index.mdx +++ b/content/docs/learn/ai/multimodal/mllm/index.mdx @@ -1,6 +1,6 @@ --- title: MLLM 多模态大模型 -description: 多模态大模型(MLLM)资料 +description: "MLLM多模态大模型技术文档,涵盖视觉token剪枝加速(Feather the Throttle)、Token激活图可解释性、GLM-4.5V推理训练、图文思维推理及视觉理解生成统一等前沿论文。适合AI研究员、CV/NLP工程师及求职者系统学习多模态模型原理与加速方法。" docId: gc6tdzkkwxn5t90nw69fibl6 --- diff --git a/content/docs/learn/ai/multimodal/multimodal-overview.mdx b/content/docs/learn/ai/multimodal/multimodal-overview.mdx index a6568ea1..70e24999 100644 --- a/content/docs/learn/ai/multimodal/multimodal-overview.mdx +++ b/content/docs/learn/ai/multimodal/multimodal-overview.mdx @@ -1,6 +1,6 @@ --- title: 多模态大模型 -description: 多模态大模型技术体系:LLaVA、QwenVL、ViT 等主流框架 +description: "内卷地狱多模态大模型技术文档,详解LLaVA视觉指令调优与QwenVL中文多模态架构,涵盖ViT编码器、MLLM对比、视频理解等核心技术。适合AI学习者、求职者及想从零入门或进阶多模态开发的CS从业者阅读。" date: "2025-01-27" tags: - multimodal diff --git a/content/docs/learn/ai/multimodal/qwenvl/index.mdx b/content/docs/learn/ai/multimodal/qwenvl/index.mdx index 0999cdf6..701419ab 100644 --- a/content/docs/learn/ai/multimodal/qwenvl/index.mdx +++ b/content/docs/learn/ai/multimodal/qwenvl/index.mdx @@ -1,6 +1,6 @@ --- title: QwenVL -description: QwenVL多模态大模型系列:发展历程、Qwen2.5-VL技术创新、微调实践 +description: "QwenVL 阿里巴巴开源多模态大模型系列技术文档,涵盖 Qwen-VL 到 Qwen2.5-VL 三代演进,核心突破包括窗口注意力提升长序列效率与动态分辨率处理。适合 AI 开发者、多模态研究者及求职者系统学习中文多模态模型技术。" date: "2025-01-27" tags: - qwen-vl diff --git a/content/docs/learn/ai/multimodal/video-mm-todo/index.mdx b/content/docs/learn/ai/multimodal/video-mm-todo/index.mdx index be7168f8..dd1dff6e 100644 --- a/content/docs/learn/ai/multimodal/video-mm-todo/index.mdx +++ b/content/docs/learn/ai/multimodal/video-mm-todo/index.mdx @@ -1,6 +1,6 @@ --- title: 多模态视频大模型 -description: 学习笔记:细粒度感知与长视频理解问题 +description: "多模态视频大模型学习笔记,聚焦细粒度感知与长视频理解两大痛点。详解动作分层建模、Token剪枝压缩、多任务训练及证据可视化方法,并介绍检索增强与层次化建模解决长视频遗忘与全局一致性难题。适合AI研究者、计算机视觉工程师及求职备考者阅读。" status: note docId: ssrhm03fw9sbogk78dmy92ml --- diff --git a/content/docs/learn/ai/multimodal/vit/index.en.mdx b/content/docs/learn/ai/multimodal/vit/index.en.mdx index 7180d727..6832d5aa 100644 --- a/content/docs/learn/ai/multimodal/vit/index.en.mdx +++ b/content/docs/learn/ai/multimodal/vit/index.en.mdx @@ -1,6 +1,6 @@ --- title: ViT Vision Encoder -description: Vision Transformer resources +description: "Learn how the ViT Vision Encoder processes images via patch embeddings and transformer layers—ideal for ML engineers exploring vision transformers." docId: xd3q72ubqzlesz8x4gewhi5r lang: en translatedFrom: zh diff --git a/content/docs/learn/ai/multimodal/vit/index.mdx b/content/docs/learn/ai/multimodal/vit/index.mdx index f6c466ba..7ac9bcbb 100644 --- a/content/docs/learn/ai/multimodal/vit/index.mdx +++ b/content/docs/learn/ai/multimodal/vit/index.mdx @@ -1,5 +1,5 @@ --- title: ViT 视觉编码器 -description: Vision Transformer 资料 +description: "ViT 视觉编码器详解:Transformer架构如何取代CNN成为图像特征提取核心,涵盖图像分块(Patch Embedding)与位置编码、自注意力机制原理。适合计算机视觉入门者、NLP转CV开发者及求职面试者系统学习。" docId: xd3q72ubqzlesz8x4gewhi5r --- diff --git a/content/docs/learn/ai/recommender-systems/recommender-roadmap.mdx b/content/docs/learn/ai/recommender-systems/recommender-roadmap.mdx index fcff1570..db809182 100644 --- a/content/docs/learn/ai/recommender-systems/recommender-roadmap.mdx +++ b/content/docs/learn/ai/recommender-systems/recommender-roadmap.mdx @@ -1,6 +1,6 @@ --- title: 推荐系统 -description: 推荐系统学习路径、实战项目、论文资源和相关比赛 +description: "推荐系统完整学习路径,覆盖协同过滤、DeepFM、DIN等传统与深度学习模型,以及LLM4Rec等大模型推荐技术。适合AI/求职开发者、推荐系统初学者及想系统掌握搜索、广告、推荐业务差异的从业者。" date: "2025-01-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.en.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.en.mdx index 7c9c5774..25670887 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.en.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.en.mdx @@ -1,6 +1,6 @@ --- title: Wang Shusen Recommender Systems Study Notes — Feature Crossing -description: "" +description: "Learn feature crossing and Factorization Machines for recommender systems, covering linear models and second-order crossed features for ML engineers." date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.mdx index 56315f8a..d7dd614b 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_crossing.mdx @@ -1,6 +1,6 @@ --- title: 王树森推荐系统学习笔记_特征交叉 -description: "" +description: "王树森推荐系统学习笔记之特征交叉,详解FM因子分解机如何通过向量内积实现二阶特征交叉,解决稀疏数据下参数爆炸问题,适合推荐系统入门者与求职备战AI算法岗的同学阅读。" date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.en.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.en.mdx index 6af45dab..00b13c39 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.en.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.en.mdx @@ -1,6 +1,6 @@ --- title: Wang Shusen Recommender Systems Study Notes — Retrieval -description: "" +description: "Learn Item-based Collaborative Filtering for recommender system retrieval, covering similarity computation and user interest estimation—ideal for AI/ML students and engineers." date: "2025-09-22" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.mdx index 7a38ed74..73ab5ec3 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval.mdx @@ -1,6 +1,6 @@ --- title: 王树森推荐系统学习笔记_召回 -description: "" +description: "王树森推荐系统学习笔记_召回,详解基于物品的协同过滤ItemCF核心原理:通过用户兴趣向量与物品相似度矩阵计算候选物品得分,并给出考虑用户喜欢程度的相似度公式。适合推荐系统入门者、AI求职面试准备者及CS自学群体。" date: "2025-09-22" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.en.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.en.mdx index 12331bb8..900398f8 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.en.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.en.mdx @@ -1,6 +1,6 @@ --- title: Wang Shusen Recommender Systems Study Notes — Cold Start -description: "" +description: "Wang Shushen's cold start notes: item cold start metrics, optimization goals for precise recommendation & incentivizing publishing, for recommender system learners." date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.mdx index 0eae5d34..8509490a 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_coldstart.mdx @@ -1,6 +1,6 @@ --- title: 王树森推荐系统学习笔记_冷启动 -description: "" +description: "王树森推荐系统学习笔记冷启动专题,详解物品冷启动评价指标与优化目标,涵盖作者侧发布渗透率、人均发布量及用户侧新笔记点击率、交互率等核心指标。适合推荐系统工程师、AI算法学习者及求职备考者阅读。" date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.en.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.en.mdx index 659f7187..fe028848 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.en.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.en.mdx @@ -1,6 +1,6 @@ --- title: Wang Shusen Recommender Systems Study Notes — Improving Metrics -description: "" +description: "Learn how to improve recommender system metrics like DAU, LT7, and LT30, with key evaluation methods for AI/ML engineers and data scientists." date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.mdx index aec5007f..145d5ea1 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_improvement.mdx @@ -1,6 +1,6 @@ --- title: 王树森推荐系统学习笔记_涨指标 -description: "" +description: "王树森推荐系统学习笔记聚焦涨指标实战方法,详解DAU、LT7/LT30留存、用户时长等核心评价指标,并系统梳理改进召回模型、优化粗排精排、提升多样性等关键技术点。适合推荐系统工程师、AI求职者及想提升推荐效果的产品与算法从业者阅读。" date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.en.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.en.mdx index 976ce574..a99c239d 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.en.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.en.mdx @@ -1,6 +1,6 @@ --- title: Wang Shusen Recommender Systems Study Notes — Ranking -description: "" +description: "Learn ranking model design for recommender systems: multi-objective scoring with CTR, like, favorite & share rate fusion. For ML engineers & AI learners." date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.mdx index 7f5ac3c2..b228ef8c 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rank.mdx @@ -1,6 +1,6 @@ --- title: 王树森推荐系统学习笔记_排序 -description: "" +description: "王树森推荐系统学习笔记_排序详解多目标排序模型,涵盖点击率、点赞率、收藏率、转发率预估及加权融合排序方法。适合推荐系统工程师、AI学习者及求职者深入理解排序阶段模型训练与类别不平衡处理。" date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.en.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.en.mdx index 404a6501..578de79e 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.en.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.en.mdx @@ -1,6 +1,6 @@ --- title: Wang Shusen Recommender Systems Study Notes — Re-Ranking -description: "" +description: "Learn re-ranking for diversity in recommender systems using attribute tags and content-based vectors—ideal for ML engineers studying Wang Shusen's notes." date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.mdx b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.mdx index 7694b724..d56ec604 100644 --- a/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.mdx +++ b/content/docs/learn/ai/recommender-systems/wangshusen_recommend_note_rerank.mdx @@ -1,6 +1,6 @@ --- title: 王树森推荐系统学习笔记_重排 -description: "" +description: "王树森推荐系统学习笔记重排篇详解推荐系统中的多样性优化,核心覆盖物品相似性度量方法(基于属性标签与CLIP图文向量表征)及MMR最大边际相关性算法。适合推荐系统工程师、算法岗求职者及AI学习者阅读。" date: "2025-09-27" tags: - recommender-systems diff --git a/content/docs/learn/ai/reinforcement-learning/ppo.en.md b/content/docs/learn/ai/reinforcement-learning/ppo.en.md new file mode 100644 index 00000000..1d583a25 --- /dev/null +++ b/content/docs/learn/ai/reinforcement-learning/ppo.en.md @@ -0,0 +1,149 @@ +--- +title: PPO +description: "Involution Hell's technical documentation on the PPO algorithm: a detailed walkthrough of the complete training pipeline (prompt batch → actor → reward model → critic) and core implementation mechanisms, including importance sampling, clipping, and KL constraint. Ideal for reinforcement learning beginners, AI job interview candidates, and CS algorithm learners." +date: "2025-10-03" +tags: + - tag-one +docId: zf8zk108oqbsg56xjyqb5txk +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +# PPO + +## 1. Complete Pipeline + +prompt batch -> actor.forward -> reward model -> critic.forward + +## 2. Algorithm Implementation + +1. **Importance sampling**: Use a single sample to perform multiple updates. This maximizes sample efficiency while correcting for the divergence between the old policy and the new policy. +2. **Clipping** (most common) **/ KL constraint**: Limits the shift between the old and new policies to prevent gradient explosion or collapse. + +### 1. Formulas + +1. Probability ratio + $$r_t(\theta) = \frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{old}}(a_t|s_t)}$$ + +$\pi$: policy +$\theta$: parameters +$a$: action +$s$: state +$t$: time step + +Personal interpretation: the relative difference in decision-making between the new and old policies given the same state. + +2. Clipped objective + +$$L^{CLIP}(\theta) = \mathbb{E}_t[min(r_t(\theta)\hat{A}_t,clip(r_t(\theta),1-\epsilon,1+\epsilon)\hat{A}_t)]$$ + +$L$: loss function +$\mathbb{E}_t$: expected value of importance-sampling results at time step $t$ +$\hat{A}_t$: advantage function at the current time step +$\epsilon$: clipping coefficient + +Personal interpretation: clipping constrains the update step size — not too large, not too small — ensuring training stability. + +3. Advantage function: + +- GAE (Generalized Advantage Estimation) + +$$A^{GAE}(a_t,s_t) = \sum^{\infty}_{l=0}(\gamma\lambda)^l\delta_{t+l}$$ + +$$\delta_t = r_t+\gamma V(s_{t+1})-V(s_t)$$ + +$\gamma$: discount factor +$r$: reward +$l$: number of delayed steps +$\lambda$: controls the bias-variance tradeoff of TD +$\lambda = 1$: equivalent to Monte Carlo return — retains every time step's TD +$\lambda = 0$: equivalent to single-step TD +$0 < \lambda < 1$: retains every time step's TD, but with different weights for each + +4. Value function regression + +$$L^{value} = \frac{1}{2}(V_{\theta}(s_t)-\hat{R}_t)^2$$ + +$V_{\theta}(s_t)$: value function at state $s_t$ at time $t$, approximated by an MLP. + +5. Entropy regularization (encourages exploration) + $$H(\pi_{\theta})=\mathbb{E_t}[-\sum_{\alpha}\pi_{\theta}(\alpha|s_t)log\pi_\theta(\alpha|s_t)]$$ + +Note: This is simply computing the entropy and taking its mean. + +6. Total loss + +$$L^{PPO} = L^{CLIP}(\theta)-c_1L_{value}+c_2H(\pi_{\theta})$$ + +## 2. Detailed Walkthrough + +### 1. Initialization Phase + +#### 1. Prompt batch + +A batch of input data. + +#### 2. actor.forward + +- Uses the backbone network to generate a response for each data point, and saves the logits for each token step by step as $log\pi_{old}$. + +#### 3. Reward + +- **Reward model** + +Purpose: scores each output to obtain a reward value; the reward is used in the formulas above to construct the loss function. The reward value $r$ is stored in a buffer for use in subsequent training. + +Architecture: an MLP + +Position: attached after the last layer of the backbone network + +Advantages: strong generalization ability + +Disadvantages: requires large amounts of labeled data, poor interpretability, poor stability, computationally expensive + +- **Reward function** + +Uses concrete rules to assign rewards, such as edit distance, repetition rate, etc. + +Advantages: computationally simple and fast, strong interpretability, stable + +Disadvantages: poor generalization — only effective in specific scenarios + +#### 4. critic.forward + +Purpose: approximates the value function of the backbone network, computes the advantage function, and stores it in a buffer for use in subsequent training. + +Architecture: an MLP + +Position: attached after the last layer of the backbone network + +### 2. Training Phase + +Repeatedly train the model using data stored in the buffer; re-sample after several rounds. + +### 3. Network Architecture + +```mermaid +graph TD + Inputs--> b[Backbone network] + b --(optional)--> reward + b --> crtirc +``` + +### 4. Dataset Construction + +- reward function + +```json +{ +role: user, +content: +} +solution: : used for reward function +``` + +# Important Note + +If there are any errors or unclear explanations, please reach out for corrections. WeChat: m1197501753 diff --git a/content/docs/learn/ai/reinforcement-learning/ppo.md b/content/docs/learn/ai/reinforcement-learning/ppo.md index 123c888a..5fd81f7c 100644 --- a/content/docs/learn/ai/reinforcement-learning/ppo.md +++ b/content/docs/learn/ai/reinforcement-learning/ppo.md @@ -1,6 +1,6 @@ --- title: PPO -description: "" +description: "内卷地狱 PPO 算法技术文档:详解完整训练链路(prompt batch→actor→reward model→critic)与核心实现方式,包括重要性采样、裁剪与KL约束机制。适合强化学习入门者、AI求职面试者及CS算法学习者阅读。" date: "2025-10-03" tags: - tag-one diff --git a/content/docs/learn/ai/reinforcement-learning/reinforcement-learning-overview.mdx b/content/docs/learn/ai/reinforcement-learning/reinforcement-learning-overview.mdx index 83fd6e51..ffdc0e75 100644 --- a/content/docs/learn/ai/reinforcement-learning/reinforcement-learning-overview.mdx +++ b/content/docs/learn/ai/reinforcement-learning/reinforcement-learning-overview.mdx @@ -1,6 +1,6 @@ --- title: 强化学习 -description: 强化学习基础理论、思维链COT、GRPO等在大模型中的应用 +description: "强化学习在大模型时代的核心应用,涵盖RLHF、PPO、GRPO及思维链推理等关键技术点。适合AI求职者、大模型算法工程师及对强化学习数学原理与项目实战感兴趣的CS学习者。" date: "2025-01-27" tags: - reinforcement-learning diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.en.md b/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.en.md index 52d59da4..a9e0b7f6 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.en.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.en.md @@ -1,6 +1,6 @@ --- title: C++ Libraries on Linux/Windows -description: "" +description: "Learn how C++ libraries work on Linux and Windows: static vs dynamic linking, header-only libraries, and how to obtain third-party libs for devs and CS learners." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.md b/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.md index 01bb4df0..a47ec8fe 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/1-cpp-libs.md @@ -1,6 +1,6 @@ --- title: linux/win上的c++库 -description: "" +description: "Linux/Windows 上 C++ 库的组成、获取与使用全解,涵盖头文件库、静态库与动态库的区别,以及通过源码编译、vcpkg、apt 等包管理器安装第三方库的方法。适合 C++ 初学者、跨平台开发者及求职备考学生阅读。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.en.md b/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.en.md index 2533ff53..339710ed 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.en.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.en.md @@ -1,6 +1,6 @@ --- title: GCC/G++ Basics -description: "" +description: "Learn GCC/G++ basics: install on Linux or Windows with MinGW, plus fix threading issues with mingw-std-threads. For new C++ developers." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.md b/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.md index 5623a78a..bd5dc1ae 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/2-base-gcc.md @@ -1,6 +1,6 @@ --- title: 基础gcc/g++ -description: "" +description: "基础gcc/g++编译工具入门,涵盖Linux与Windows双平台安装配置,重点解决MinGW下thread库的踩坑修复(需补充mingw-std-threads头文件并添加-D_WIN32_WINNT=0x0501编译参数),适合刚接触C++编程、需要搭建本地编译环境并解决常见兼容性问题的初学者与求职备考者。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/3-make.en.md b/content/docs/learn/cs/cpp-backend/easy-compile/3-make.en.md index 4bb37496..29e03001 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/3-make.en.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/3-make.en.md @@ -1,6 +1,6 @@ --- title: Building with Make -description: "" +description: "Learn how Make manages file dependencies and timestamps for automated builds — essential for developers and CS learners on involutionhell.com." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/3-make.md b/content/docs/learn/cs/cpp-backend/easy-compile/3-make.md index 080de044..b8be4e5b 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/3-make.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/3-make.md @@ -1,6 +1,6 @@ --- title: Make编译 -description: "" +description: "Make编译详解:基于依赖关系与时间戳的自动化构建工具,通过检查源文件与目标文件的修改时间差智能触发重新编译。适合CS/AI方向求职者、C++项目开发者及希望提升构建效率的工程师阅读,掌握Makefile基本语法与规则配置。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.en.md b/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.en.md index 4f704128..7db5e205 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.en.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.en.md @@ -1,6 +1,6 @@ --- title: CMake -description: "" +description: "Learn CMake for C++ projects: compile executables or libraries, keep build files separate from source. For CS learners & developers." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.md b/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.md index 4c646c75..f4319c4f 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/4-cmake.md @@ -1,6 +1,6 @@ --- title: CMake -description: "" +description: "CMake 编译 C++ 项目核心指令详解,覆盖从 CMakeLists.txt 配置、构建目录隔离到生成可执行文件与静态/动态库的完整流程,适合 C++ 初学者、求职准备者及希望系统掌握 CMake 构建工具的开发者阅读。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.en.md b/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.en.md index 42e87658..3bfc00bd 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.en.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.en.md @@ -1,6 +1,6 @@ --- title: vcpkg Package Manager -description: "" +description: "Learn vcpkg's Classic and Manifest modes for C++ dependency management, plus CMake integration setup for open-source developers." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.md b/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.md index af893590..9d4be0c8 100644 --- a/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.md +++ b/content/docs/learn/cs/cpp-backend/easy-compile/5-vcpkg.md @@ -1,6 +1,6 @@ --- title: vcpkg包管理器 -description: "" +description: "vcpkg包管理器详解:经典模式直接安装库并手动配置CMake包含目录,清单模式通过vcpkg.json自动管理依赖并集成CMake工具链。适合C++开发者、使用CMake构建系统的项目团队,以及需要统一管理第三方库或创建私有注册表的开发者。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.en.md b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.en.md index c51d81ca..e8a0c1df 100644 --- a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.en.md +++ b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.en.md @@ -1,6 +1,6 @@ --- title: Handwritten Thread Pool -description: "" +description: "Learn how to build a handwritten thread pool with blocking queues (single & double-queue versions), covering constructor, post, and destructor interfaces for CS/AI developers." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.md b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.md index 6b2ae1de..f6c4ac60 100644 --- a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.md +++ b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/1-handwritten-threadpool.md @@ -1,6 +1,6 @@ --- title: 手写线程池 -description: "" +description: "手写线程池实现详解,涵盖单队列与双队列阻塞队列设计、锁竞争优化及批量搬运机制,适合求职面试、C++后端开发及并发编程学习者阅读。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.en.md b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.en.md index e97c6719..e6e835b8 100644 --- a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.en.md +++ b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.en.md @@ -1,6 +1,6 @@ --- title: Handwritten Fixed-Size Memory Pool -description: "" +description: "Learn to build a fixed-size memory pool from scratch in C, covering struct design and block allocation/freeing—ideal for systems programmers and CS learners." date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.md b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.md index 0cbb09c5..44c40cd6 100644 --- a/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.md +++ b/content/docs/learn/cs/cpp-backend/handwritten-pool-components/2-handwritten-mempool1.md @@ -1,6 +1,6 @@ --- title: 手写定长内存池 -description: "" +description: "手写定长内存池技术文档详解内存池结构体mempool_s设计与实现,涵盖memp_create创建、memp_alloc分配、memp_free回收及memp_destory销毁等核心接口。适合C/C++开发者、系统编程学习者及追求高性能内存管理的求职者阅读。" date: "2025-09-29" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/mempool-simple.en.mdx b/content/docs/learn/cs/cpp-backend/mempool-simple.en.mdx index 3e08345b..2d305726 100644 --- a/content/docs/learn/cs/cpp-backend/mempool-simple.en.mdx +++ b/content/docs/learn/cs/cpp-backend/mempool-simple.en.mdx @@ -1,6 +1,6 @@ --- title: Handwritten Memory Pool (Simple Fixed-Size) -description: "" +description: "Learn to build a simple fixed-size memory pool in C. Covers block allocation, deallocation, and O(1) performance. For systems programmers and CS learners." date: "2025-09-27" tags: - cpp-backend diff --git a/content/docs/learn/cs/cpp-backend/mempool-simple.mdx b/content/docs/learn/cs/cpp-backend/mempool-simple.mdx index bec779e1..5e53f41d 100644 --- a/content/docs/learn/cs/cpp-backend/mempool-simple.mdx +++ b/content/docs/learn/cs/cpp-backend/mempool-simple.mdx @@ -1,6 +1,6 @@ --- title: 手写内存池(简单定长) -description: "" +description: "内卷地狱 involutionhell.com 技术文档:手写内存池(简单定长)实现。详解定长 block 分配与回收机制,包含设计图、代码结构及使用示例。适合正在学习 C/C++ 系统编程、准备面试或想提升内存管理底层能力的 CS/AI 求职者阅读。" date: "2025-09-27" tags: - cpp-backend diff --git a/content/docs/learn/cs/data-structures/array/01-static-array.mdx b/content/docs/learn/cs/data-structures/array/01-static-array.mdx index fb8c3a7d..7f8ae89a 100644 --- a/content/docs/learn/cs/data-structures/array/01-static-array.mdx +++ b/content/docs/learn/cs/data-structures/array/01-static-array.mdx @@ -1,6 +1,6 @@ --- title: 静态数组 -description: 静态数组的实现原理、特性与使用场景 +description: "静态数组是数组最基本的形式,大小在编译时确定且运行期间不可改变,支持O(1)随机访问和连续内存布局,对缓存友好且无额外元数据开销,但插入删除操作需移动元素效率为O(n)。适合准备CS面试、学习数据结构基础或从事嵌入式与高性能计算的开发者。" date: "2024-01-04" tags: - static-array diff --git a/content/docs/learn/cs/data-structures/array/02-dynamic-array.mdx b/content/docs/learn/cs/data-structures/array/02-dynamic-array.mdx index 45cf5a92..4a15219e 100644 --- a/content/docs/learn/cs/data-structures/array/02-dynamic-array.mdx +++ b/content/docs/learn/cs/data-structures/array/02-dynamic-array.mdx @@ -1,6 +1,6 @@ --- title: 动态数组 -description: 动态数组的实现原理、扩容机制与性能分析 +description: "动态数组核心机制与扩容策略详解,涵盖倍增扩容与黄金比例扩容的摊还分析,对比访问O(1)、插入删除O(n)等时间复杂度。适合准备算法面试、学习数据结构基础或需要理解动态数组底层实现的CS/AI求职者。" date: "2024-01-05" tags: - dynamic-array diff --git a/content/docs/learn/cs/data-structures/array/index.en.mdx b/content/docs/learn/cs/data-structures/array/index.en.mdx index 1a6fb7ba..668b2ed7 100644 --- a/content/docs/learn/cs/data-structures/array/index.en.mdx +++ b/content/docs/learn/cs/data-structures/array/index.en.mdx @@ -1,6 +1,6 @@ --- title: Array -description: "Basic concepts, characteristics, and applications of arrays" +description: "Learn array data structure basics: O(1) random access, contiguous memory, fixed size tradeoffs. For CS students and self-taught developers." date: "2024-01-03" tags: - array diff --git a/content/docs/learn/cs/data-structures/array/index.mdx b/content/docs/learn/cs/data-structures/array/index.mdx index 6b0e2aee..84de8a93 100644 --- a/content/docs/learn/cs/data-structures/array/index.mdx +++ b/content/docs/learn/cs/data-structures/array/index.mdx @@ -1,6 +1,6 @@ --- title: 数组 -description: 数组的基本概念、特性与应用场景 +description: "内卷地狱 involutionhell.com 数组技术文档:详解数组作为最基础数据结构的随机访问 O(1) 特性与内存连续存储优势,对比静态数组与动态数组的适用场景及插入删除 O(n) 开销。适合正在学习数据结构与算法、准备 CS 求职面试或需要夯实编程基础的开发者阅读。" date: "2024-01-03" tags: - array diff --git a/content/docs/learn/cs/data-structures/index.en.mdx b/content/docs/learn/cs/data-structures/index.en.mdx index fa62aa4c..a2f0349b 100644 --- a/content/docs/learn/cs/data-structures/index.en.mdx +++ b/content/docs/learn/cs/data-structures/index.en.mdx @@ -1,6 +1,6 @@ --- title: Data Structures Fundamentals -description: Basic concepts and core knowledge of data structures +description: "Learn data structures fundamentals: linear (arrays, stacks, queues) and non-linear (trees, graphs, hash tables) for efficient algorithm design. Ideal for CS beginners." date: "2024-01-02" tags: - data-structures diff --git a/content/docs/learn/cs/data-structures/index.mdx b/content/docs/learn/cs/data-structures/index.mdx index f10987e1..21ed8cc6 100644 --- a/content/docs/learn/cs/data-structures/index.mdx +++ b/content/docs/learn/cs/data-structures/index.mdx @@ -1,6 +1,6 @@ --- title: 数据结构基础 -description: 数据结构的基本概念与核心知识 +description: "数据结构基础页面详解数组、链表、栈、队列等线性结构及树、图、哈希表等非线性结构,重点分析时间与空间复杂度、应用场景与实现细节。适合CS/AI初学者、求职面试者及想系统巩固数据结构核心知识的开发者。" date: "2024-01-02" tags: - data-structures diff --git a/content/docs/learn/cs/data-structures/linked-list/01-singly-linked-list.mdx b/content/docs/learn/cs/data-structures/linked-list/01-singly-linked-list.mdx index b50e08b7..811f2500 100644 --- a/content/docs/learn/cs/data-structures/linked-list/01-singly-linked-list.mdx +++ b/content/docs/learn/cs/data-structures/linked-list/01-singly-linked-list.mdx @@ -1,6 +1,6 @@ --- title: 单链表 -description: "单链表的实现、操作与应用" +description: "单链表是链表数据结构的基础形式,每个节点包含数据域与指向下一节点的指针。本文详解节点结构、插入与删除操作中的指针变化、反转算法等关键技术点,并涵盖常见面试题如环检测、找中点和合并有序链表。适合准备算法面试的CS/AI求职者、正在学习数据结构的编程初学者阅读。" date: "2024-01-07" tags: - singly-linked-list diff --git a/content/docs/learn/cs/data-structures/linked-list/index.mdx b/content/docs/learn/cs/data-structures/linked-list/index.mdx index 9c271aad..c3dbed60 100644 --- a/content/docs/learn/cs/data-structures/linked-list/index.mdx +++ b/content/docs/learn/cs/data-structures/linked-list/index.mdx @@ -1,6 +1,6 @@ --- title: 链表 -description: 链表的基本概念、类型与应用场景 +description: "内卷地狱技术文档:链表数据结构详解,涵盖单链表、双链表、循环链表三种类型及节点结构、指针域、插入删除操作的时间复杂度分析(头部O(1)、尾部O(n))。适合准备算法面试的CS/AI求职者、复习数据结构的学生阅读。" date: "2024-01-06" tags: - linked-list diff --git a/content/docs/learn/cs/frontend/frontend-learning/index.en.mdx b/content/docs/learn/cs/frontend/frontend-learning/index.en.mdx index 5b56b912..baa24f8c 100644 --- a/content/docs/learn/cs/frontend/frontend-learning/index.en.mdx +++ b/content/docs/learn/cs/frontend/frontend-learning/index.en.mdx @@ -1,6 +1,6 @@ --- title: What Frontend Skills Should 2025 New Graduates Learn? -description: "" +description: "Frontend skills guide for 2025 new grads: HTML/CSS basics, Flexbox, Tailwind CSS, and using LLMs for job-ready learning." date: "2025-09-19" tags: - frontend diff --git a/content/docs/learn/cs/frontend/frontend-learning/index.mdx b/content/docs/learn/cs/frontend/frontend-learning/index.mdx index 5016bb2a..efd46e02 100644 --- a/content/docs/learn/cs/frontend/frontend-learning/index.mdx +++ b/content/docs/learn/cs/frontend/frontend-learning/index.mdx @@ -1,6 +1,6 @@ --- title: 2025年应届生前端需要学习什么 -description: "" +description: "2025年应届生前端学习路线指南,涵盖HTML/CSS/JavaScript基础、React框架与状态管理(useContext、Redux RTK、Zustand)、Tailwind必学及网络请求fetch与axios对比。适合准备秋招的应届生、转行前端初学者及想系统梳理知识点的求职者。" date: "2025-09-19" tags: - frontend diff --git a/content/docs/learn/cs/frontend/index.en.mdx b/content/docs/learn/cs/frontend/index.en.mdx index 71523f20..d0559155 100644 --- a/content/docs/learn/cs/frontend/index.en.mdx +++ b/content/docs/learn/cs/frontend/index.en.mdx @@ -1,6 +1,6 @@ --- title: Frontend -description: Comprehensive frontend development learning resources +description: "Explore frontend development resources on involutionhell.com: HTML, CSS, React, Node.js, and interview essentials for job seekers." date: "2025-09-19" tags: - frontend diff --git a/content/docs/learn/cs/frontend/index.mdx b/content/docs/learn/cs/frontend/index.mdx index dc0c2b94..dfdfbc23 100644 --- a/content/docs/learn/cs/frontend/index.mdx +++ b/content/docs/learn/cs/frontend/index.mdx @@ -1,6 +1,6 @@ --- title: frontend -description: 前端 学习资源全面整理 +description: "内卷地狱前端技术文档页汇总完整学习路径与面试资源,覆盖HTML、CSS、JavaScript、React、Redux、Node.js、Webpack、Vite、Docker、Kubernetes等核心技术栈,适合准备国内外前端求职的开发者与自学者系统提升。" date: "2025-09-19" tags: - frontend diff --git a/content/docs/learn/cs/index.en.mdx b/content/docs/learn/cs/index.en.mdx index 6e5121a4..451b442b 100644 --- a/content/docs/learn/cs/index.en.mdx +++ b/content/docs/learn/cs/index.en.mdx @@ -1,6 +1,6 @@ --- title: Computer Science -description: Computer Science Knowledge Collection +description: "Explore core CS concepts: data structures, algorithms, complexity theory, and programming paradigms. Ideal for students and self-learners building a strong foundation." date: "2024-01-01" tags: - computer-science diff --git a/content/docs/learn/cs/index.mdx b/content/docs/learn/cs/index.mdx index 8daa8754..1af0cba2 100644 --- a/content/docs/learn/cs/index.mdx +++ b/content/docs/learn/cs/index.mdx @@ -1,6 +1,6 @@ --- title: Computer Science -description: Computer Science Knowledge Collection +description: "内卷地狱计算机科学知识库,覆盖数据结构与算法(含复杂度理论)、编程语言与编译器原理等核心领域。适合CS/AI求职者、自学开发者及考研学生系统复习,按基础→算法→高级主题顺序高效进阶。" date: "2024-01-01" tags: - computer-science diff --git a/content/docs/learn/index.en.mdx b/content/docs/learn/index.en.mdx new file mode 100644 index 00000000..261b10f5 --- /dev/null +++ b/content/docs/learn/index.en.mdx @@ -0,0 +1,21 @@ +--- +title: Learn +description: "The Learn section of Involution Hell provides subject-organized study materials for AI and CS. AI topics include LLMs, Agents, reinforcement learning, multimodal models, and foundational mathematics; CS topics cover data structures, algorithms, systems programming, and backend engineering. Ideal for developers and job seekers looking to systematically build their AI/CS knowledge or prepare for technical interviews." +date: "2026-04-18" +docId: lrn0001index2026041800000001 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +import { SectionIndex } from "@/app/components/docs/SectionIndex"; + +The **Learn** zone of Involution Hell — subject-organized study materials. + +- **AI**: Full-stack AI topics including LLMs, Agents, RL, recommender systems, multimodal models, and foundational mathematics +- **CS**: Data structures, algorithms, systems programming, and backend engineering + +Feeling lost halfway through your studies? Check out the frontrunners' experience in `/community`, or get interview-ready with `/career`. + + diff --git a/content/docs/learn/index.mdx b/content/docs/learn/index.mdx index 89b33ce5..39c81c8b 100644 --- a/content/docs/learn/index.mdx +++ b/content/docs/learn/index.mdx @@ -1,6 +1,6 @@ --- title: Learn -description: 系统学习 AI / CS / 数学三大主题,从基础打底到专业方向。 +description: "Involution Hell 学区的技术文档页,按学科分类提供 AI 与 CS 系统学习资料。AI 方向覆盖 LLM、Agent、强化学习、多模态及基础数学;CS 方向涵盖数据结构、算法、系统编程与后端工程。适合正在系统提升 AI/CS 技能、准备求职或寻找学习路径的开发者与求职者阅读。" date: "2026-04-18" docId: lrn0001index2026041800000001 --- diff --git a/content/docs/projects/ai-town.en.mdx b/content/docs/projects/ai-town.en.mdx index ecf3d9a1..1c46933a 100644 --- a/content/docs/projects/ai-town.en.mdx +++ b/content/docs/projects/ai-town.en.mdx @@ -1,6 +1,6 @@ --- title: AI Town Design Document -description: "" +description: "Explore AI Town's lightweight simulation with multi-agent NPCs that remember you, using O-R-P-A framework and Godot 4—ideal for open-source devs and AI enthusiasts." date: "2025-10-18" tags: - ai-agent-simulation diff --git a/content/docs/projects/ai-town.mdx b/content/docs/projects/ai-town.mdx index 7a99ec3b..664bfabf 100644 --- a/content/docs/projects/ai-town.mdx +++ b/content/docs/projects/ai-town.mdx @@ -1,6 +1,6 @@ --- title: AI小镇策划 -description: "" +description: "AI小镇策划页详解多智能体NPC驱动的轻模拟社交游戏,核心技术点包括O-R-P-A观察检索计划行动框架与短期记忆日终摘要机制,适合Godot引擎开发者、多智能体系统学习者及开源社区贡献者阅读。" date: "2025-10-18" tags: - ai-agent-simulation diff --git a/content/docs/projects/index.en.mdx b/content/docs/projects/index.en.mdx new file mode 100644 index 00000000..3152ad56 --- /dev/null +++ b/content/docs/projects/index.en.mdx @@ -0,0 +1,16 @@ +--- +title: Projects +description: "Involution Hell's documentation hub for open-source projects initiated and maintained by community members, spanning CS/AI job-hunting tools and learning resources. Perfect for developers and job seekers looking to gain project experience, contribute to open source, or prepare for technical interviews." +date: "2026-04-18" +docId: prj0001index2026041800000001 +lang: en +translatedFrom: zh +translatedAt: 2026-05-11T00:00:00Z +translatorAgent: claude-sonnet-4-6 +--- + +import { SectionIndex } from "@/app/components/docs/SectionIndex"; + +Open-source projects initiated and maintained by community members. PRs welcome — come join us. + + diff --git a/content/docs/projects/index.mdx b/content/docs/projects/index.mdx index 55fc36b6..c1aa4743 100644 --- a/content/docs/projects/index.mdx +++ b/content/docs/projects/index.mdx @@ -1,6 +1,6 @@ --- title: Projects -description: Involution Hell 社区维护的开源项目文档集合。 +description: "内卷地狱技术文档页汇总社区成员发起与维护的开源项目,涵盖CS/AI/求职实战工具与学习资源,适合正在备战面试、寻求项目经验或希望参与开源贡献的开发者与求职者。" date: "2026-04-18" docId: prj0001index2026041800000001 --- diff --git a/content/docs/projects/multimodal-rl.mdx b/content/docs/projects/multimodal-rl.mdx index 61d2829f..23beae29 100644 --- a/content/docs/projects/multimodal-rl.mdx +++ b/content/docs/projects/multimodal-rl.mdx @@ -1,6 +1,6 @@ --- title: 多模态强化学习项目(MVP 目标) -description: 构建轻量化的多模态理解与生成系统,实现从视觉感知到语言表达的闭环,并引入强化学习与答案可视化生成。 +description: "多模态强化学习项目MVP目标文档,详解构建轻量化多模态理解与生成系统的完整闭环,涵盖图像识别、语义检索与文本生成,并引入RLHF/DPO微调与用户反馈优化模型表现。适合AI/CS求职者、多模态方向研究者及希望掌握CLIP、BLIP-2、LLaVA等模型实战的开发者阅读。" date: "2025-10-17" tags: - projects diff --git a/dev_docs/seo_meta_description.md b/dev_docs/seo_meta_description.md new file mode 100644 index 00000000..389fdabb --- /dev/null +++ b/dev_docs/seo_meta_description.md @@ -0,0 +1,157 @@ +# SEO Meta Description 三层方案 + +## 为什么需要这东西 + +2026-05 Bing Webmaster Tools 报告:involutionhell.com 有 **118 个页面 meta description 太短** +(< 150 字符),评为 Moderate SEO 问题。 + +根因不是代码 bug,是**内容缺失**: + +- docs 页面(`app/[locale]/docs/[...slug]/page.tsx:165`)的 `generateMetadata` 直接读 MDX + frontmatter 的 `description` 字段,没有 fallback; +- `content/docs/` 下 292 个 MDX 中: + - **96 个** 完全没有 `description` 字段(绝大多数是程序化导入的 leetcode 题解) + - **67 个** `description: ""` 空字符串 + - **35 个** description < 20 字符("First page" 这种) + - **56 个** description 20-60 字符(合格但偏短) + - 仅 **38 个** ≥ 60 字符 + +这条 Bing 告警不是 hard error,是 ranking signal —— description 缺失时搜索引擎会从正文 +随便抓一段做摘要,质量不可控,间接拉低 CTR 和排名。 + +## 方案:三层叠加 + +### Layer 1 — 代码层兜底(`lib/seo-description.ts`) + +所有 docs 页的 `generateMetadata` 都过 `ensureSeoDescription()`,把短/空/缺失的 +description 自动拼接到 ≥ 80 字符: + +```ts +description: ensureSeoDescription({ + description: page.data.description, + title: page.data.title, + sectionPath: slug.slice(0, -1), // 当前页的分区面包屑 + locale, +}); +``` + +兜底文本结构: + +``` +[作者原 description 如有] 主题:{title}。 所属分区:{breadcrumb}。 站点 tagline。 +``` + +中英文 tagline 各一份,按 `locale` 选。 + +**影响范围**:以下 4 处页面 metadata 都已接入: + +| 文件 | 用途 | +| ------------------------------------------ | ------------------------------------------------------- | +| `app/[locale]/docs/[...slug]/page.tsx:165` | docs 动态路由 generateMetadata + TechArticle JSON-LD | +| `app/[locale]/docs/page.tsx:47` | docs 根落地页 | +| `app/[locale]/events/[id]/page.tsx:57` | 活动详情页(兜底用户/管理员录入的 `event.description`) | +| `app/[locale]/feed/page.tsx:24` | 社区分享墙 | + +**作用**:立即消除 Bing 告警,不动 content/。但兜底文本是模板化拼接, +搜索摘要质量稀薄 —— 这是 Layer 1 的局限。 + +### Layer 2 — CI lint 阻止再积累低质量 description + +`scripts/check-frontmatter-description.mjs` 在 pre-commit + GitHub Actions PR +检查新增/修改的 MDX,强制 `description` 字段 ≥ 60 字符。 + +豁免规则: + +- `content/docs/career/interview-prep/leetcode/` 全部豁免 —— 程序化导入太多, + Layer 1 兜底已能用 +- `*_translated.md` / `*_translated.mdx` —— 机翻产物,等人工 review 时再补 + +**接入位置**: + +- `.husky/pre-commit`:`pnpm check:frontmatter`(默认 `--changed` 模式) +- `.github/workflows/content-check.yml`:同上,PR 上下文自动从 `GITHUB_BASE_REF` + diff 找改动文件 + +**只看不阻塞模式**:`pnpm check:frontmatter:all` 扫所有文件输出报表,但不退出 +非 0;用于本地一次性看现状。 + +### Layer 3 — 离线脚本回填 description 写入 frontmatter(`scripts/generate-descriptions.mjs`) + +把存量 253 个 description 缺失/空/极短的 MDX 回填精准描述。 + +两种生成策略: + +1. **默认(推荐)**:所有文件走 DeepSeek API + - 输入:title + filename + 正文前 800 字符(清洗 import / 代码块 / MDX 组件) + - 输出:单行 description,中文文档 80-100 字、英文文档 120-160 字符 + - leetcode 题解会被额外提示"以 LeetCode {题号}. {题名} 题解 — 开头" + - 成本:~$0.05 总 token 成本(DeepSeek 2026-05 价目) + +2. **`--leetcode-only`(离线模式)**:仅 leetcode 走文件名+正文模板拼接,不调 LLM + - 用于无 `DEEPSEEK_API_KEY` 时的 fallback + - 模板覆盖:题号 + 题名 + 正文首句 + 通用 tail + +**用法**: + +```bash +# 1. dry-run(默认),生成 scripts/.descriptions-report.json 供 review +DEEPSEEK_API_KEY=sk-xxx node scripts/generate-descriptions.mjs + +# 2. 看 dry-run 结果后真写回 frontmatter +DEEPSEEK_API_KEY=sk-xxx node scripts/generate-descriptions.mjs --apply + +# 3. 试运行只跑前 N 个 +DEEPSEEK_API_KEY=sk-xxx node scripts/generate-descriptions.mjs --limit=5 + +# 4. 离线模式(leetcode 模板) +node scripts/generate-descriptions.mjs --leetcode-only --apply +``` + +**安全设计**: + +- 默认 dry-run,绝不动 content;`--apply` 才真写 +- `gray-matter` 保留其他 frontmatter 字段(title / date / docId / lang 等) +- 已合格(≥ 60 字符)的 description 跳过 —— 重跑幂等 +- DeepSeek 调用失败的不写,留待重跑 +- 输出 < 50 字符的不写,标记在 report 的 `skippedTooShort` 里 +- API key 只从 env 读,不进任何 commit + +## 验证 + +```bash +# 看 Layer 1 兜底是否在跑:访问随便一个无 description 的 leetcode 页面 +curl -s https://involutionhell.com/zh/docs/career/interview-prep/leetcode/1004... | grep ' content/docs/__test.mdx +git add content/docs/__test.mdx +pnpm check:frontmatter # 预期退出码 1 + +# Layer 3 dry-run,看 report +DEEPSEEK_API_KEY=sk-xxx node scripts/generate-descriptions.mjs --limit=5 +cat scripts/.descriptions-report.json | jq '.results[] | {file, length, after}' +``` + +## 决策记录 + +- **为什么 lint 阈值是 60 字符而非 Bing 推荐的 150**:60 是保守值,照顾老贡献者 + 适应;Layer 1 兜底会把渲染时实际长度补到 ≥ 80。两道防线足够。 +- **为什么 leetcode 豁免 lint**:96 个题解是程序化导入的,没人会手写 + description;强制写人为操作太重,靠 Layer 1 兜底 + Layer 3 模板/LLM 一次性补齐 + 即可。 +- **为什么用 DeepSeek 而非更贵的模型**:本任务对模型推理要求不高(看 800 字 + 正文摘要成一句话),DeepSeek-chat 足够;成本 $0.05 vs GPT-4 的 $5+,差 100 倍。 +- **为什么不直接在 source.config.ts 装 remark 插件自动生成 description**: + fumadocs 已经把 frontmatter 转为 `page.data`,在 metadata 层加 fallback 比改 + frontmatter pipeline 侵入性小、回退安全。 + +## 相关文件 + +- `lib/seo-description.ts` — Layer 1 兜底函数 +- `tests/seo-description.test.ts` — 兜底函数单元测试 +- `scripts/check-frontmatter-description.mjs` — Layer 2 lint +- `scripts/generate-descriptions.mjs` — Layer 3 离线生成 +- `app/[locale]/docs/[...slug]/page.tsx` — 主要消费方 +- `.husky/pre-commit` — 接入点 +- `.github/workflows/content-check.yml` — 接入点 diff --git a/lib/seo-description.ts b/lib/seo-description.ts new file mode 100644 index 00000000..35458585 --- /dev/null +++ b/lib/seo-description.ts @@ -0,0 +1,105 @@ +/** + * @file lib/seo-description.ts + * @description + * SEO meta description 统一兜底工具。 + * + * 背景:Bing Webmaster Tools 2026-05 报告 118 个页面 meta description 太短 + * (< 150 字符)。根因是 docs 页面(fumadocs)直接读 MDX frontmatter 的 + * `description` 字段,没有 fallback;社区贡献者经常漏写或写得过短: + * + * - 96 个 leetcode 题解完全没有 description 字段(程序化导入,没人手动补) + * - 67 个 description: ""(贡献者留空) + * - 35 个 < 20 字符("First page" 这种) + * + * 这个工具实现"代码层兜底": + * 1. 如果 description >= MIN_LENGTH,原样返回(信任作者) + * 2. 否则拼接 [原 description] + [当前页 title] + [所属分区面包屑] + [站点 tagline] + * 拼到 80+ 字符,保证搜索引擎抓得到完整摘要 + * + * 设计原则: + * - 不要 LLM、不要数据库、纯字符串拼接(Edge runtime 友好) + * - 拼接结果对人类可读("主题:xxx。 所属分区:xxx › xxx。 站点 tagline") + * - 中英双语 tagline 各一份,按 locale 选 + * - title === slug 末段时不重复(避免 "主题:A。 所属分区:x › A。") + * + * 注意:这是兜底,不是质量保证。理想路径仍是作者手写精准 description; + * 真正解决靠 scripts/check-frontmatter-description.mjs 的 CI lint + * 强制新增内容必须写 description。 + */ + +const SITE_TAGLINE_ZH = + "Involution Hell 社区文档 — 算法、系统设计、面试经验与求职指南,由社区贡献维护的开源学习知识库。"; +const SITE_TAGLINE_EN = + "Involution Hell — open-source community knowledge base on algorithms, system design, interview prep, and software engineering."; + +/** + * meta description 最短长度阈值。Bing 推荐 150-160 字符,但实际 80+ 已不被 + * 判定为"too short"。设 80 在质量和兜底成本之间折中:太低被 Bing 继续报警, + * 太高会让兜底文本占据搜索摘要前半,淹没作者真实写的内容。 + */ +export const MIN_SEO_DESCRIPTION_LENGTH = 80; + +export interface EnsureSeoDescriptionOpts { + /** 作者原写的 description,可能为 null/undefined/空字符串/过短 */ + description?: string | null; + /** 当前页标题,用于兜底拼接 */ + title?: string | null; + /** + * 所属分区路径段数组(不含当前页本身),例如: + * /docs/career/interview-prep/leetcode/xxx → ["career", "interview-prep", "leetcode"] + * 用于在兜底文本里拼面包屑。空数组时不拼分区。 + */ + sectionPath?: string[]; + /** 当前页所属语言("zh" / "en"),决定 tagline 语种 */ + locale?: string; +} + +/** + * 把短/空/缺失的 description 兜底到 >= MIN_SEO_DESCRIPTION_LENGTH 字符。 + * + * @example + * ensureSeoDescription({ description: "", title: "2335. Min Time", sectionPath: ["career", "interview-prep", "leetcode"], locale: "zh" }) + * // → "主题:2335. Min Time。 所属分区:career › interview-prep › leetcode。 Involution Hell 社区文档 — ..." + */ +export function ensureSeoDescription(opts: EnsureSeoDescriptionOpts): string { + const raw = (opts.description ?? "").trim(); + if (raw.length >= MIN_SEO_DESCRIPTION_LENGTH) { + return raw; + } + + const isEn = opts.locale === "en"; + const tagline = isEn ? SITE_TAGLINE_EN : SITE_TAGLINE_ZH; + + // 拼接顺序:原 description(短但是有) → title → 分区 → tagline + const parts: string[] = []; + + if (raw) { + // 作者写了但是短,保留作为前缀,补标点防黏连 + const punctuated = /[。.!!??]$/.test(raw) ? raw : `${raw}。`; + parts.push(punctuated); + } + + // title 拼接:如果 sectionPath 末段(已是 title slug)与 title 重复, + // 跳过 title 段避免 "主题:A 所属分区:x › A" 这种重复 + const titleStr = (opts.title ?? "").trim(); + if (titleStr) { + parts.push(isEn ? `Topic: ${titleStr}.` : `主题:${titleStr}。`); + } + + // sectionPath 拼接:面包屑用 › 分隔,URL-decode 让中文目录显示正常 + if (opts.sectionPath && opts.sectionPath.length > 0) { + const decoded = opts.sectionPath.map((seg) => { + try { + return decodeURIComponent(seg); + } catch { + return seg; // 非法 URL 序列,保留原样 + } + }); + const breadcrumb = decoded.join(" › "); + parts.push(isEn ? `Section: ${breadcrumb}.` : `所属分区:${breadcrumb}。`); + } + + parts.push(tagline); + + return parts.join(" ").trim(); +} diff --git a/package.json b/package.json index 347c6417..95f51978 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,9 @@ "lint:fix": "eslint . --ext .ts,.tsx --fix", "typecheck": "tsc --noEmit", "check:pnpm-version": "node scripts/check-pnpm-version.mjs", - "check:lockfile": "node scripts/check-lockfile.mjs" + "check:lockfile": "node scripts/check-lockfile.mjs", + "check:frontmatter": "node scripts/check-frontmatter-description.mjs", + "check:frontmatter:all": "node scripts/check-frontmatter-description.mjs --all" }, "dependencies": { "@ai-sdk/google": "^2.0.14", diff --git a/scripts/check-frontmatter-description.mjs b/scripts/check-frontmatter-description.mjs new file mode 100644 index 00000000..e7172426 --- /dev/null +++ b/scripts/check-frontmatter-description.mjs @@ -0,0 +1,293 @@ +#!/usr/bin/env node +/** + * MDX frontmatter `description` 字段校验脚本 + * + * 背景 + * - Bing Webmaster Tools 2026-05 报告 118 个页面 meta description 太短。 + * - 根因:fumadocs 的 docs 页面直接读 MDX frontmatter `description`,没兜底; + * 而 content/docs/ 下 292 个 MDX 里 96 个完全没写 description、67 个写成空字符串、 + * 35 个 < 20 字符。 + * - 代码层兜底已经做了(lib/seo-description.ts),让所有页面 meta description >= 80 字符。 + * 但兜底是"补救",不是质量保证 —— 兜底版本是模板化拼接,比作者手写的精准内容差。 + * + * 这个脚本的角色 + * - 在 CI/pre-commit 阶段拦截 **新增/修改** 的 MDX 文件,强制作者手写 description。 + * - 老文件不返工(grandfather)—— 由 Layer 1 代码兜底兜住。 + * - 自动豁免 leetcode/ 目录和 _translated 后缀文件(前者程序化导入太多,后者是机翻产物)。 + * + * 用法 + * node scripts/check-frontmatter-description.mjs # 默认 --changed + * node scripts/check-frontmatter-description.mjs --changed # 只检查 git 已变更的 mdx(PR/pre-commit 用) + * node scripts/check-frontmatter-description.mjs --all # 扫全部,输出统计报表(不退出非 0) + * node scripts/check-frontmatter-description.mjs --strict # 配合 --all 时遇违规退 1(暂不开放,老文件太多) + * + * 退出码 + * 0 通过 / 报表模式 + * 1 --changed 模式下发现新增/修改的 MDX 违反规则 + * + * 接入位置 + * - .husky/pre-commit (pnpm check:frontmatter — --changed 模式) + * - .github/workflows/content-check.yml (CI PR 检查) + * + * 后续可考虑 + * - 把 leetcode/ 豁免改为"必须用模板生成",由 Layer 3 的回填脚本保证 + * - 把 MIN_LENGTH 提到 100 字符(先保守 60 让老贡献者适应) + */ + +import fs from "node:fs"; +import path from "node:path"; +import { execSync } from "node:child_process"; +import matter from "gray-matter"; + +const ROOT = process.cwd(); +const DOCS_DIR = path.join(ROOT, "content", "docs"); + +/** + * 最短 description 字符数。 + * 60 是保守值:Bing 推荐 150-160,但严苛的话所有新 PR 会被拦。先 60 让贡献者适应。 + * Layer 1 代码兜底会进一步把太短的拼到 80+,所以最终用户看到的搜索摘要不会真的过短。 + */ +const MIN_LENGTH = 60; + +/** + * 豁免路径前缀。这些目录下的 MDX 不强制写 description: + * - leetcode/: 96 个题解程序化导入,没人会手写;Layer 1 兜底已用 title+面包屑生成可用摘要 + */ +const EXEMPT_PATH_PREFIXES = ["content/docs/career/interview-prep/leetcode/"]; + +/** + * 豁免文件后缀。 + * - _translated.md: 机翻产物,原文 description 不一定能直接译过来;豁免后等人工 review 时补 + */ +const EXEMPT_FILE_SUFFIXES = ["_translated.md", "_translated.mdx"]; + +function isExempt(relPath) { + if (EXEMPT_PATH_PREFIXES.some((p) => relPath.startsWith(p))) return true; + if (EXEMPT_FILE_SUFFIXES.some((s) => relPath.endsWith(s))) return true; + return false; +} + +/** + * 解析 mdx 文件返回 { description, hasField }。 + * 用 gray-matter 兼容引号 / 多行 / YAML 边缘 case;正则 dirty parsing 不可靠。 + */ +function parseDescription(absPath) { + const raw = fs.readFileSync(absPath, "utf-8"); + let parsed; + try { + parsed = matter(raw); + } catch (e) { + return { + hasField: false, + description: "", + parseError: e?.message ?? String(e), + }; + } + const data = parsed.data ?? {}; + const hasField = Object.prototype.hasOwnProperty.call(data, "description"); + const description = + typeof data.description === "string" ? data.description.trim() : ""; + return { hasField, description }; +} + +/** + * 列出所有 MDX 文件(递归 content/docs/)。 + */ +function listAllMdxFiles() { + const out = []; + function walk(dir) { + const entries = fs.readdirSync(dir, { withFileTypes: true }); + for (const entry of entries) { + const full = path.join(dir, entry.name); + if (entry.isDirectory()) { + walk(full); + } else if ( + entry.isFile() && + (entry.name.endsWith(".mdx") || entry.name.endsWith(".md")) + ) { + out.push(path.relative(ROOT, full)); + } + } + } + if (!fs.existsSync(DOCS_DIR)) return []; + walk(DOCS_DIR); + return out; +} + +/** + * 列出当前 PR / pre-commit 阶段已变更的 mdx 文件。 + * + * pre-commit: git diff --cached 取暂存区 + * GitHub Actions PR: 取 PR head vs base 的 diff(GITHUB_BASE_REF 提供 base 分支) + * 本地 (无 staged 时):取 working tree vs HEAD,确保开发期跑也能看到刚改的文件 + */ +function listChangedMdxFiles() { + const candidates = new Set(); + + /** 把 git 输出按行加进 candidates;只保留 content/docs 下的 mdx/md */ + const addLines = (raw) => { + raw + .split("\n") + .map((l) => l.trim()) + .filter(Boolean) + .filter( + (l) => + l.startsWith("content/docs/") && + (l.endsWith(".mdx") || l.endsWith(".md")), + ) + .forEach((l) => candidates.add(l)); + }; + + // Strategy 1: GitHub Actions PR 上下文 + const baseRef = process.env.GITHUB_BASE_REF; + if (baseRef) { + try { + // 确保 base 分支引用本地可达(actions/checkout 默认浅克隆) + execSync(`git fetch origin ${baseRef} --depth=1`, { stdio: "ignore" }); + const out = execSync( + `git diff --name-only --diff-filter=AM origin/${baseRef}...HEAD`, + { encoding: "utf-8" }, + ); + addLines(out); + return [...candidates]; + } catch { + // 失败回退到本地策略 + } + } + + // Strategy 2: pre-commit 暂存区 + try { + const staged = execSync("git diff --cached --name-only --diff-filter=AM", { + encoding: "utf-8", + }); + addLines(staged); + } catch { + /* 非 git 仓库或无 staged,忽略 */ + } + + // Strategy 3: working tree vs HEAD(本地开发期跑脚本时看刚改未 stage 的文件) + try { + const wt = execSync("git diff --name-only --diff-filter=AM HEAD", { + encoding: "utf-8", + }); + addLines(wt); + } catch { + /* 忽略 */ + } + + return [...candidates]; +} + +function emitError({ file, message, line = 1 }) { + // GitHub Actions annotation format,PR 里会显示在文件具体行 + if (process.env.GITHUB_ACTIONS) { + console.error(`::error file=${file},line=${line}::${message}`); + } else { + console.error(` ✗ ${file}: ${message}`); + } +} + +function emitWarning({ file, message }) { + if (process.env.GITHUB_ACTIONS) { + console.warn(`::warning file=${file}::${message}`); + } else { + console.warn(` ⚠ ${file}: ${message}`); + } +} + +function main() { + const args = new Set(process.argv.slice(2)); + const mode = args.has("--all") ? "all" : "changed"; + const strict = args.has("--strict"); + + let files = mode === "all" ? listAllMdxFiles() : listChangedMdxFiles(); + + if (files.length === 0) { + if (mode === "changed") { + console.log( + "✅ check:frontmatter — no changed MDX files in content/docs/", + ); + process.exit(0); + } else { + console.log("⚠️ check:frontmatter --all — no MDX files found"); + process.exit(0); + } + } + + // 报表统计 + const stats = { + total: files.length, + exempt: 0, + missing: [], + empty: [], + short: [], + ok: 0, + }; + + for (const rel of files) { + if (isExempt(rel)) { + stats.exempt++; + continue; + } + const abs = path.join(ROOT, rel); + if (!fs.existsSync(abs)) continue; + const { hasField, description } = parseDescription(abs); + if (!hasField) { + stats.missing.push(rel); + } else if (!description) { + stats.empty.push(rel); + } else if (description.length < MIN_LENGTH) { + stats.short.push({ rel, len: description.length }); + } else { + stats.ok++; + } + } + + const violations = + stats.missing.length + stats.empty.length + stats.short.length; + + console.log(`\n📋 check:frontmatter (mode=${mode})`); + console.log(` scanned: ${stats.total} files`); + console.log(` exempt : ${stats.exempt} (leetcode/ + _translated)`); + console.log(` ok : ${stats.ok}`); + console.log(` missing description field: ${stats.missing.length}`); + console.log(` empty description : ${stats.empty.length}`); + console.log(` short < ${MIN_LENGTH} chars : ${stats.short.length}`); + + if (violations === 0) { + console.log("\n✅ all checked files have description >= " + MIN_LENGTH); + process.exit(0); + } + + console.log(`\n🚫 ${violations} file(s) need a longer description:\n`); + for (const rel of stats.missing) { + emitError({ + file: rel, + message: `Missing \`description\` in frontmatter. Add a 60-160 char summary describing what this page covers (used by search engines and AI assistants).`, + }); + } + for (const rel of stats.empty) { + emitError({ + file: rel, + message: `Frontmatter has \`description: ""\` (empty). Fill in 60-160 chars describing the page topic for SEO.`, + }); + } + for (const { rel, len } of stats.short) { + emitError({ + file: rel, + message: `\`description\` is too short (${len} chars, need >= ${MIN_LENGTH}). Expand to 60-160 chars summarizing the page.`, + }); + } + + console.log( + `\n💡 tip: 在 frontmatter 里加 description: "..." 字段。\n 推荐 60-160 字符,覆盖:本页主题 + 关键技术点 + 适用读者。\n leetcode/ 目录和 _translated.md 文件自动豁免(由代码层兜底,见 lib/seo-description.ts)。`, + ); + + // changed 模式默认严格;all 模式只在 --strict 下报错 + if (mode === "changed" || strict) { + process.exit(1); + } + process.exit(0); +} + +main(); diff --git a/scripts/generate-descriptions.mjs b/scripts/generate-descriptions.mjs new file mode 100644 index 00000000..6c588410 --- /dev/null +++ b/scripts/generate-descriptions.mjs @@ -0,0 +1,693 @@ +#!/usr/bin/env node +/** + * 离线脚本:为 content/docs/ 下 description 缺失/空/极短的 MDX 文件生成 description。 + * + * 背景 + * - Bing Webmaster 2026-05 报告 118 个页面 meta description 太短。 + * - Layer 1 代码兜底(lib/seo-description.ts)已经消除 Bing 告警,但兜底文本是 + * 模板化拼接("主题:xxx。 所属分区:xxx › xxx。 站点 tagline"),语义稀薄。 + * - 这个脚本生成"作者级精准摘要"写回 frontmatter,让搜索结果摘要质量真正提升。 + * + * 两种生成策略 + * - LeetCode 题解(content/docs/career/interview-prep/leetcode/*):模板化生成 + * `LeetCode {题号}. {题名}({语言})— {正文首段摘要} · Involution Hell 社区刷题笔记` + * 这些是程序化导入的,不调 LLM,速度快、零成本、可重复。 + * + * - 其他文档:DeepSeek API 生成 80-130 字符 description + * - 输入:title + 正文前 800 字符 + * - 输出:单行 description,不带引号 + * - 语言跟随原文(.en.* 后缀用英文,其他用中文) + * + * 用法 + * # dry-run(默认):生成 scripts/.descriptions-report.json,不动 mdx + * node scripts/generate-descriptions.mjs + * + * # 真写回 frontmatter(先 review JSON 报表再跑) + * DEEPSEEK_API_KEY=sk-xxx node scripts/generate-descriptions.mjs --apply + * + * # 跳过 LLM,只处理 leetcode 模板(不需要 API key) + * node scripts/generate-descriptions.mjs --leetcode-only --apply + * + * # 只看哪些文件会被处理,不调 LLM、不写文件 + * node scripts/generate-descriptions.mjs --list + * + * 安全 + * - 默认 dry-run,不动 content;--apply 才真写回 + * - 写回前会保留原 frontmatter 其他字段(gray-matter) + * - 重跑幂等:已合格的 description 不动 + * - DeepSeek 失败的不写,留待重跑 + * + * 成本估算 + * - ~158 个文档 * 1000 tokens 输入 / 100 tokens 输出 + * - DeepSeek chat:约 $0.05 总成本(按 2026-05 价目) + */ + +import fs from "node:fs"; +import path from "node:path"; +import matter from "gray-matter"; + +const ROOT = process.cwd(); +const DOCS_DIR = path.join(ROOT, "content", "docs"); +const REPORT_PATH = path.join(ROOT, "scripts", ".descriptions-report.json"); + +const MIN_LENGTH = 60; +const TARGET_LENGTH_MIN = 80; +const TARGET_LENGTH_MAX = 150; +const BODY_CHARS_FOR_LLM = 800; // 给 LLM 的正文截取长度 + +const DEEPSEEK_BASE = ( + process.env.DEEPSEEK_BASE_URL || "https://api.deepseek.com" +).replace(/\/+$/, ""); +const DEEPSEEK_MODEL = process.env.DEEPSEEK_MODEL || "deepseek-chat"; + +/** + * 判断文件是否英文页面(.en.{md,mdx} 后缀) + */ +function isEnglishFile(relPath) { + return /\.en\.(md|mdx)$/i.test(relPath); +} + +/** + * 是否 leetcode 路径 + */ +function isLeetcodePath(relPath) { + return relPath.startsWith("content/docs/career/interview-prep/leetcode/"); +} + +/** + * 列出所有 MDX 文件(递归) + */ +function listMdxFiles() { + const out = []; + (function walk(dir) { + if (!fs.existsSync(dir)) return; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name); + if (entry.isDirectory()) walk(full); + else if ( + entry.isFile() && + (entry.name.endsWith(".mdx") || entry.name.endsWith(".md")) + ) { + out.push(path.relative(ROOT, full)); + } + } + })(DOCS_DIR); + return out; +} + +/** + * 从 mdx 文件读出 frontmatter 和正文 + */ +function readMdx(relPath) { + const abs = path.join(ROOT, relPath); + const raw = fs.readFileSync(abs, "utf-8"); + const { data, content } = matter(raw); + return { abs, raw, data: data ?? {}, content: content ?? "" }; +} + +/** + * 把正文清洗成纯文本片段(给 LLM 做摘要原料)。 + * 移除: + * - import / export 语句 + * - HTML/MDX 组件标签(...) + * - 代码块(```...```) + * - 行内代码 / 链接括号 + * - 多余空白 + */ +function cleanBody(body) { + let s = body; + // import/export + s = s.replace(/^\s*(import|export)\s+.*$/gm, ""); + // 围栏代码块 + s = s.replace(/```[\s\S]*?```/g, ""); + // 行内代码 + s = s.replace(/`[^`\n]+`/g, ""); + // MDX/HTML 标签:循环 replace 直到 stable,避免嵌套残留如 "<