← 2026-04-15 📂 All Days 2026-04-17 →

🔄 复习日 / Review Day

今天是复习日!回顾过去4天的内容。

📝 Quick Quiz — 3 Mini-Reviews

Pick 3 topics from 3 different sections.

Q1: [🏗️ System Design] 在设计分布式唯一ID生成器(如 Twitter Snowflake)时,为什么时间戳部分通常放在最高位(最左边)? / When designing a distributed unique ID generator (like Twitter Snowflake), why is the timestamp component usually placed in the most significant bits (leftmost)?

<details><summary>显示答案 / Show Answer</summary>

将时间戳放在高位可以保证生成的ID大致按时间递增(Time-sortable)。这对于数据库索引(如 B+ 树)非常友好,能有效减少页分裂,提高插入性能。 / Placing the timestamp in the most significant bits ensures that the generated IDs are roughly sortable by time. This is highly beneficial for database indexing (like B+ trees) as it reduces page splits and improves insertion performance.

</details>

Q2: [💻 Algorithms] 在解决“有效括号” (Valid Parentheses) 问题时,为什么栈 (Stack) 是最合适的数据结构? / When solving the "Valid Parentheses" problem, why is a Stack the most appropriate data structure?

<details><summary>显示答案 / Show Answer</summary>

因为括号的匹配遵循“后进先出”(LIFO)的原则。最后遇到的未闭合左括号,必须最先被相应的右括号闭合。栈完美契合了这种处理顺序。 / Because parenthesis matching follows a "Last-In-First-Out" (LIFO) principle. The most recently encountered unclosed left parenthesis must be closed first by a corresponding right parenthesis. A stack perfectly models this order of operations.

</details>

Q3: [🎨 Frontend] 在 React 中,受控组件 (Controlled) 和非受控组件 (Uncontrolled) 处理表单数据的主要区别是什么? / In React, what is the main difference between Controlled and Uncontrolled components for handling form data?

<details><summary>显示答案 / Show Answer</summary>

受控组件的表单数据由 React 的 state 管理,每次输入都会触发状态更新和重新渲染;而非受控组件的表单数据由 DOM 自身管理,通常使用 ref 在需要时(如提交时)一次性读取值。 / In a Controlled component, form data is managed by React state, and every input triggers a state update and re-render. In an Uncontrolled component, form data is managed by the DOM itself, and values are typically read once using a ref when needed (e.g., on submit).

</details>

💡 复习巩固记忆,螺旋式上升。

📅 明天继续新内容!