← 2026-06-07 📂 All Days 2026-06-09 →

🔄 复习日 / Review Day — Day 60

📊 NeetCode: 50/150 · SysDesign: 49/40 · Behavioral: 49/40 · Frontend: 37/50 · AI: 24/30

🔥 59-day streak!


🔄 复习日 / Review Day

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

This is Day 60 — let's consolidate what you've learned in Days 56–59.


📝 Quick Quiz — 3 Mini-Reviews

Pick 3 topics from 3 different sections.


Q1: [🏗️ System Design] — Design a Collaborative Editor (Google Docs)

你在设计一个类 Google Docs 的协同编辑器。两个用户同时编辑同一段文字:User A 在位置 5 插入 "hello",User B 几乎同时删除了位置 3–7 的内容。这两个操作应该如何合并,才能保证两个用户最终看到一致的内容?

You're designing a collaborative editor. Two users edit simultaneously: User A inserts "hello" at position 5, User B deletes characters at positions 3–7. How do you merge these operations to reach eventual consistency?

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

This is the Operational Transformation (OT) problem — the core challenge in collaborative editors.

Key insight: When User B's delete operation arrives at the server after User A's insert, the server must transform B's operation to account for A's change. B's delete range (3–7) must be shifted to (3–12) because A inserted 5 characters before position 7.

Two main approaches:

  1. OT (Operational Transformation) — Google Docs' original approach. A central server serializes all operations and transforms concurrent ops against each other. Simple client, complex server.
  2. CRDTs (Conflict-free Replicated Data Types) — Each character gets a unique ID and tombstone on delete. No coordination needed. Used by Figma, Linear. More complex data structure, simpler convergence.

Common mistake: Using naive "last write wins" — this causes data loss. The editor must track the intention of each edit, not just its position.

The tradeoff: OT requires a central coordinator (single point of failure), CRDTs have higher memory overhead but work peer-to-peer.

</details>


Q2: [💻 Algorithms] — Balanced Binary Tree & Diameter of Binary Tree

给定一棵二叉树,如何在 一次 DFS 中同时计算:(1) 树是否平衡(任意节点左右子树高度差 ≤ 1),(2) 树的直径(最长路径经过的节点数)?提示:这两道题用了同一个"后序递归"模式。

Given a binary tree, how do you compute both (1) whether it's height-balanced and (2) its diameter — in a single DFS pass? Hint: both problems share the same post-order recursion pattern.

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

Both problems use post-order DFS (process children before parent) and return the height from each recursive call.

Balanced Binary Tree:

def isBalanced(root):
    def height(node):
        if not node: return 0
        left = height(node.left)
        right = height(node.right)
        if left == -1 or right == -1 or abs(left - right) > 1:
            return -1  # -1 = "unbalanced" sentinel
        return 1 + max(left, right)
    return height(root) != -1

Diameter of Binary Tree:

def diameterOfBinaryTree(root):
    diameter = 0
    def height(node):
        nonlocal diameter
        if not node: return 0
        left = height(node.left)
        right = height(node.right)
        diameter = max(diameter, left + right)  # path through this node
        return 1 + max(left, right)
    height(root)
    return diameter

Key insight: In both, each node returns its height to the parent, but also performs local work (balance check or diameter update) at that node. The diameter at any node = left_height + right_height. This is the "return height, update global" pattern — reuse it for Maximum Path Sum too!

</details>


Q3: [🤖 AI] — Reinforcement Learning from AI Feedback (RLAIF)

RLHF 需要人类标注者给模型输出打分,成本很高。RLAIF 如何解决这个问题?它的核心假设是什么,又有什么局限性?

RLHF requires expensive human annotators to score model outputs. How does RLAIF solve this, what's its core assumption, and what are its limitations?

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

RLAIF (RL from AI Feedback) replaces human raters with a larger/stronger AI model (the "judge") to score the outputs of the model being trained.

How it works:

  1. Sample two responses from the student model for the same prompt
  2. Ask the judge AI: "Which response is better and why?"
  3. Use those AI-generated preference labels to train the reward model
  4. Run PPO/DPO optimization as usual

Core assumption: The judge AI has better judgment than the student model — i.e., it can reliably distinguish good from bad outputs. This breaks down for tasks where no current model can reliably evaluate quality (e.g., novel math proofs, highly specialized domains).

Real-world use: Anthropic's Constitutional AI uses RLAIF-style self-critique. Google's "Gemini trained with RLAIF" paper showed competitive results with human feedback at a fraction of the cost.

Limitations:

  • Judge bias propagation — if the judge has systematic biases (prefers verbose answers, favors certain styles), the student inherits them
  • Evaluation ceiling — can't surpass the judge's own capabilities
  • Reward hacking — student may learn to fool the judge rather than actually improve

The trend: humans set high-level principles → AI generates the feedback at scale. Humans still needed for rare/hard cases.

</details>


💡 复习巩固记忆,螺旋式上升。Review sharpens what you've learned — each pass builds stronger mental models.

📅 明天继续新内容!Tomorrow: Day 61 — new content continues.