leetcode-teacher
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLeetCode Teacher
LeetCode 导师
An interactive technical interview preparation teacher that generates engaging coding playgrounds with real-world product challenges, pattern recognition training, and multi-language support.
一款交互式的技术面试备考导师,可生成包含真实产品挑战的引人入胜的编码练习环境,提供模式识别训练和多语言支持。
What This Skill Does
该技能的功能
Transforms technical interview prep into interactive, practical experiences:
- Interactive Code Playgrounds - Browser-based coding environments with instant feedback
- Multi-Language Support - Python, TypeScript, Kotlin, Swift
- Real Product Challenges - Practical scenarios from real companies
- Pattern Recognition - Learn the 20 essential coding patterns
- Progressive Difficulty - Easy → Medium → Hard → Expert
- Instant Feedback - Run tests in real-time with detailed explanations
- Technique Teaching - Master problem-solving approaches
将技术面试备考转化为交互式、实践性的体验:
- 交互式编码练习环境 - 基于浏览器的编码环境,提供即时反馈
- 多语言支持 - Python、TypeScript、Kotlin、Swift
- 真实产品挑战 - 来自真实企业的实际场景
- 模式识别 - 学习20种核心编码模式
- 渐进式难度 - 简单 → 中等 → 困难 → 专家
- 即时反馈 - 实时运行测试并提供详细解释
- 技巧教学 - 掌握解题方法
Why This Skill Matters
该技能的重要性
Traditional LeetCode practice:
- Abstract, disconnected problems
- No pattern recognition guidance
- Trial and error approach
- Intimidating for beginners
- Limited language options
With this skill:
- Real product scenarios
- Pattern-based learning
- Guided problem-solving
- Progressive difficulty curve
- Multi-language practice
- Interactive, fun interface
传统LeetCode练习:
- 抽象、与实际脱节的问题
- 无模式识别指导
- 试错式学习
- 对初学者不友好
- 语言选项有限
使用该技能:
- 真实产品场景
- 基于模式的学习
- 指导性解题
- 渐进式难度曲线
- 多语言练习
- 交互式、有趣的界面
Core Principles
核心原则
1. Pattern-First Learning
1. 以模式为先的学习
- Recognize problem patterns
- Apply proven templates
- Build intuition through practice
- Master one pattern at a time
- 识别问题模式
- 应用经过验证的模板
- 通过练习培养直觉
- 一次掌握一种模式
2. Real Product Context
2. 真实产品背景
- Instagram feed ranking
- Uber trip matching
- Netflix recommendation
- Slack message search
- Amazon inventory management
- Instagram动态排名
- Uber行程匹配
- Netflix推荐系统
- Slack消息搜索
- 亚马逊库存管理
3. Progressive Difficulty
3. 渐进式难度
- Start with fundamentals
- Build complexity gradually
- Unlock advanced patterns
- Track skill progression
- 从基础开始
- 逐步增加复杂度
- 解锁高级模式
- 跟踪技能进度
4. Multi-Language Mastery
4. 多语言精通
- Practice in your target language
- Compare implementations
- Learn language-specific tricks
- Interview in any language
- 使用目标语言练习
- 对比不同实现方式
- 学习特定语言的技巧
- 用任意语言应对面试
5. Interactive Learning
5. 交互式学习
- Write code in browser
- Run tests instantly
- Get hints when stuck
- See optimal solutions
- Track progress
- 在浏览器中编写代码
- 即时运行测试
- 遇到困难时获取提示
- 查看最优解
- 跟踪进度
Problem Patterns Covered
涵盖的问题模式
Array & String Patterns
数组与字符串模式
1. Two Pointers
Pattern: Use two pointers to scan array
Use when: Need to find pairs, triplets, or subarrays
Example: "Find Instagram users who like each other"
Complexity: O(n) time, O(1) space2. Sliding Window
Pattern: Maintain a window that slides through array
Use when: Need to find subarray with certain property
Example: "Find trending topics in last N tweets"
Complexity: O(n) time, O(k) space3. Fast & Slow Pointers
Pattern: Two pointers moving at different speeds
Use when: Detect cycles, find middle element
Example: "Detect circular dependency in package manager"
Complexity: O(n) time, O(1) space1. 双指针
Pattern: Use two pointers to scan array
Use when: Need to find pairs, triplets, or subarrays
Example: "Find Instagram users who like each other"
Complexity: O(n) time, O(1) space2. 滑动窗口
Pattern: Maintain a window that slides through array
Use when: Need to find subarray with certain property
Example: "Find trending topics in last N tweets"
Complexity: O(n) time, O(k) space3. 快慢指针
Pattern: Two pointers moving at different speeds
Use when: Detect cycles, find middle element
Example: "Detect circular dependency in package manager"
Complexity: O(n) time, O(1) spaceTree & Graph Patterns
树与图模式
4. Tree BFS
Pattern: Level-order traversal using queue
Use when: Need level-by-level processing
Example: "Show friends by degree of connection"
Complexity: O(n) time, O(w) space (w = max width)5. Tree DFS
Pattern: Preorder, inorder, or postorder traversal
Use when: Need to explore all paths
Example: "Find all paths in file system"
Complexity: O(n) time, O(h) space (h = height)6. Graph BFS
Pattern: Explore neighbors level by level
Use when: Shortest path, level-based exploration
Example: "Find shortest connection path on LinkedIn"
Complexity: O(V + E) time, O(V) space7. Graph DFS
Pattern: Explore as far as possible before backtracking
Use when: Path finding, cycle detection
Example: "Detect circular references in social graph"
Complexity: O(V + E) time, O(V) space8. Topological Sort
Pattern: Order nodes by dependencies
Use when: Task scheduling, build systems
Example: "Order courses based on prerequisites"
Complexity: O(V + E) time, O(V) space4. 树的BFS
Pattern: Level-order traversal using queue
Use when: Need level-by-level processing
Example: "Show friends by degree of connection"
Complexity: O(n) time, O(w) space (w = max width)5. 树的DFS
Pattern: Preorder, inorder, or postorder traversal
Use when: Need to explore all paths
Example: "Find all paths in file system"
Complexity: O(n) time, O(h) space (h = height)6. 图的BFS
Pattern: Explore neighbors level by level
Use when: Shortest path, level-based exploration
Example: "Find shortest connection path on LinkedIn"
Complexity: O(V + E) time, O(V) space7. 图的DFS
Pattern: Explore as far as possible before backtracking
Use when: Path finding, cycle detection
Example: "Detect circular references in social graph"
Complexity: O(V + E) time, O(V) space8. 拓扑排序
Pattern: Order nodes by dependencies
Use when: Task scheduling, build systems
Example: "Order courses based on prerequisites"
Complexity: O(V + E) time, O(V) spaceDynamic Programming Patterns
动态规划模式
9. 0/1 Knapsack
Pattern: Include or exclude each item
Use when: Optimization with constraints
Example: "Select best ads within budget"
Complexity: O(n * capacity) time and space10. Unbounded Knapsack
Pattern: Can use item unlimited times
Use when: Coin change, combinations
Example: "Minimum transactions to reach balance"
Complexity: O(n * target) time and space11. Fibonacci Numbers
Pattern: Current state depends on previous states
Use when: Climbing stairs, tiling problems
Example: "Ways to navigate through app screens"
Complexity: O(n) time, O(1) space optimized12. Longest Common Subsequence
Pattern: Compare two sequences
Use when: Diff tools, edit distance
Example: "Find similar code snippets"
Complexity: O(m * n) time and space9. 0/1背包
Pattern: Include or exclude each item
Use when: Optimization with constraints
Example: "Select best ads within budget"
Complexity: O(n * capacity) time and space10. 完全背包
Pattern: Can use item unlimited times
Use when: Coin change, combinations
Example: "Minimum transactions to reach balance"
Complexity: O(n * target) time and space11. 斐波那契数列
Pattern: Current state depends on previous states
Use when: Climbing stairs, tiling problems
Example: "Ways to navigate through app screens"
Complexity: O(n) time, O(1) space optimized12. 最长公共子序列
Pattern: Compare two sequences
Use when: Diff tools, edit distance
Example: "Find similar code snippets"
Complexity: O(m * n) time and spaceOther Essential Patterns
其他核心模式
13. Modified Binary Search
Pattern: Binary search on sorted or rotated array
Use when: Search in O(log n)
Example: "Find version when bug was introduced"
Complexity: O(log n) time, O(1) space14. Top K Elements
Pattern: Use heap to track K largest/smallest
Use when: Finding top items
Example: "Get top K trending hashtags"
Complexity: O(n log k) time, O(k) space15. K-Way Merge
Pattern: Merge K sorted arrays/lists
Use when: Combining sorted data
Example: "Merge activity feeds from K users"
Complexity: O(n log k) time, O(k) space16. Backtracking
Pattern: Try all possibilities with pruning
Use when: Generate permutations, combinations
Example: "Generate all valid parentheses combinations"
Complexity: Varies, often exponential17. Union Find
Pattern: Track connected components
Use when: Network connectivity, grouping
Example: "Find connected friend groups"
Complexity: O(α(n)) amortized per operation18. Intervals
Pattern: Merge, insert, or find overlapping intervals
Use when: Calendar scheduling, time ranges
Example: "Find free meeting slots"
Complexity: O(n log n) time, O(n) space19. Monotonic Stack
Pattern: Maintain increasing/decreasing stack
Use when: Next greater/smaller element
Example: "Stock price span calculation"
Complexity: O(n) time, O(n) space20. Trie
Pattern: Prefix tree for string operations
Use when: Autocomplete, prefix matching
Example: "Implement search autocomplete"
Complexity: O(m) time per operation (m = word length)13. 变种二分查找
Pattern: Binary search on sorted or rotated array
Use when: Search in O(log n)
Example: "Find version when bug was introduced"
Complexity: O(log n) time, O(1) space14. 前K个元素
Pattern: Use heap to track K largest/smallest
Use when: Finding top items
Example: "Get top K trending hashtags"
Complexity: O(n log k) time, O(k) space15. K路归并
Pattern: Merge K sorted arrays/lists
Use when: Combining sorted data
Example: "Merge activity feeds from K users"
Complexity: O(n log k) time, O(k) space16. 回溯法
Pattern: Try all possibilities with pruning
Use when: Generate permutations, combinations
Example: "Generate all valid parentheses combinations"
Complexity: Varies, often exponential17. 并查集
Pattern: Track connected components
Use when: Network connectivity, grouping
Example: "Find connected friend groups"
Complexity: O(α(n)) amortized per operation18. 区间问题
Pattern: Merge, insert, or find overlapping intervals
Use when: Calendar scheduling, time ranges
Example: "Find free meeting slots"
Complexity: O(n log n) time, O(n) space19. 单调栈
Pattern: Maintain increasing/decreasing stack
Use when: Next greater/smaller element
Example: "Stock price span calculation"
Complexity: O(n) time, O(n) space20. 字典树(Trie)
Pattern: Prefix tree for string operations
Use when: Autocomplete, prefix matching
Example: "Implement search autocomplete"
Complexity: O(m) time per operation (m = word length)Real Product Challenge Examples
真实产品挑战示例
Easy Level
简单难度
Instagram: Like Counter
Real Scenario: Count how many times user's posts were liked today
Pattern: Hash Map
Data Structure: Dictionary/HashMap
Languages: Python, TypeScript, Kotlin, SwiftSlack: Unread Messages
Real Scenario: Find first unread message in channel
Pattern: Linear Search with Flag
Data Structure: Array
Teaches: Early terminationUber: Calculate Fare
Real Scenario: Compute trip cost based on distance and time
Pattern: Simple Calculation
Data Structure: Numbers
Teaches: Math operations, roundingInstagram:点赞计数器
Real Scenario: Count how many times user's posts were liked today
Pattern: Hash Map
Data Structure: Dictionary/HashMap
Languages: Python, TypeScript, Kotlin, SwiftSlack:未读消息
Real Scenario: Find first unread message in channel
Pattern: Linear Search with Flag
Data Structure: Array
Teaches: Early terminationUber:计算车费
Real Scenario: Compute trip cost based on distance and time
Pattern: Simple Calculation
Data Structure: Numbers
Teaches: Math operations, roundingMedium Level
中等难度
Netflix: Top N Recommendations
Real Scenario: Find top N movies by rating
Pattern: Top K Elements (Heap)
Data Structure: Priority Queue
Teaches: Heap operations, partial sortingAmazon: Inventory Management
Real Scenario: Find products running low in stock
Pattern: Filtering with Threshold
Data Structure: Array + HashMap
Teaches: Multi-criteria filteringTwitter: Trending Hashtags
Real Scenario: Find most used hashtags in time window
Pattern: Sliding Window + Frequency Count
Data Structure: Queue + HashMap
Teaches: Time-based window managementLinkedIn: Degrees of Connection
Real Scenario: Find connection path between two users
Pattern: BFS
Data Structure: Graph (Adjacency List)
Teaches: Shortest path, level trackingNetflix:前N个推荐内容
Real Scenario: Find top N movies by rating
Pattern: Top K Elements (Heap)
Data Structure: Priority Queue
Teaches: Heap operations, partial sorting亚马逊:库存管理
Real Scenario: Find products running low in stock
Pattern: Filtering with Threshold
Data Structure: Array + HashMap
Teaches: Multi-criteria filteringTwitter:热门话题标签
Real Scenario: Find most used hashtags in time window
Pattern: Sliding Window + Frequency Count
Data Structure: Queue + HashMap
Teaches: Time-based window managementLinkedIn:人脉连接度数
Real Scenario: Find connection path between two users
Pattern: BFS
Data Structure: Graph (Adjacency List)
Teaches: Shortest path, level trackingHard Level
困难难度
Google Calendar: Find Meeting Slots
Real Scenario: Find free time slots for all attendees
Pattern: Interval Merging
Data Structure: Array of Intervals
Teaches: Sorting, merging overlapping intervalsSpotify: Playlist Shuffle
Real Scenario: True random shuffle avoiding artist repetition
Pattern: Modified Fisher-Yates
Data Structure: Array
Teaches: Randomization with constraintsGitHub: Merge Conflict Resolution
Real Scenario: Find longest common subsequence in files
Pattern: Dynamic Programming (LCS)
Data Structure: 2D Array
Teaches: DP state definition, optimizationAirbnb: Search Ranking
Real Scenario: Rank listings by multiple weighted criteria
Pattern: Custom Sorting + Heap
Data Structure: Priority Queue with Comparator
Teaches: Complex comparisons, tie-breaking谷歌日历:查找会议时段
Real Scenario: Find free time slots for all attendees
Pattern: Interval Merging
Data Structure: Array of Intervals
Teaches: Sorting, merging overlapping intervalsSpotify:播放列表随机排序
Real Scenario: True random shuffle avoiding artist repetition
Pattern: Modified Fisher-Yates
Data Structure: Array
Teaches: Randomization with constraintsGitHub:合并冲突解决
Real Scenario: Find longest common subsequence in files
Pattern: Dynamic Programming (LCS)
Data Structure: 2D Array
Teaches: DP state definition, optimizationAirbnb:搜索排名
Real Scenario: Rank listings by multiple weighted criteria
Pattern: Custom Sorting + Heap
Data Structure: Priority Queue with Comparator
Teaches: Complex comparisons, tie-breakingInteractive Playground Example
交互式练习环境示例
Python Playground
Python练习环境
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🚀 LeetCode Teacher - Two Sum (Instagram Likes)</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
color: white;
}
.container {
max-width: 1400px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.panel {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: 30px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
h1 {
font-size: 2.5em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.difficulty {
display: inline-block;
padding: 5px 15px;
border-radius: 20px;
font-size: 0.9em;
font-weight: bold;
margin-bottom: 20px;
}
.easy { background: #4CAF50; }
.medium { background: #FF9800; }
.hard { background: #F44336; }
.problem {
background: rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 10px;
margin: 20px 0;
line-height: 1.6;
}
.code-editor {
width: 100%;
min-height: 400px;
background: #1e1e1e;
color: #d4d4d4;
font-family: 'SF Mono', monospace;
font-size: 14px;
padding: 20px;
border-radius: 10px;
border: none;
resize: vertical;
}
.controls {
display: flex;
gap: 10px;
margin: 20px 0;
}
.btn {
padding: 12px 30px;
border: none;
border-radius: 10px;
font-size: 1em;
font-weight: bold;
cursor: pointer;
transition: transform 0.2s;
}
.btn-run {
background: linear-gradient(135deg, #4CAF50, #45a049);
color: white;
}
.btn-hint {
background: linear-gradient(135deg, #FF9800, #F57C00);
color: white;
}
.btn-solution {
background: linear-gradient(135deg, #2196F3, #1976D2);
color: white;
}
.btn:hover { transform: translateY(-2px); }
.output {
background: #1e1e1e;
color: #4CAF50;
padding: 20px;
border-radius: 10px;
min-height: 100px;
font-family: monospace;
white-space: pre-wrap;
margin-top: 20px;
}
.test-case {
background: rgba(255, 255, 255, 0.05);
padding: 15px;
border-radius: 8px;
margin: 10px 0;
border-left: 4px solid #4CAF50;
}
.test-failed {
border-left-color: #F44336;
}
.stats {
display: flex;
justify-content: space-around;
margin: 20px 0;
padding: 20px;
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
}
.stat {
text-align: center;
}
.stat-value {
font-size: 2em;
font-weight: bold;
color: #FFD700;
}
.pattern-badge {
display: inline-block;
background: rgba(255, 215, 0, 0.2);
color: #FFD700;
padding: 5px 15px;
border-radius: 15px;
margin: 5px;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="container">
<!-- Left Panel: Problem -->
<div class="panel">
<h1>🎯 Two Sum</h1>
<span class="difficulty easy">Easy</span>
<span class="pattern-badge">Pattern: Hash Map</span>
<span class="pattern-badge">Array</span>
<div class="problem">
<h3>📱 Real Product Scenario: Instagram Likes</h3>
<p>You're building Instagram's "Mutual Likes" feature. Given an array of user IDs who liked your post and a target sum, find two users whose IDs add up to the target.</p>
<h4 style="margin-top: 20px;">Problem:</h4>
<p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return indices of two numbers that add up to <code>target</code>.</p>
<h4 style="margin-top: 20px;">Example:</h4>
<code style="display: block; padding: 10px; background: rgba(0,0,0,0.3); border-radius: 5px;">
Input: nums = [2, 7, 11, 15], target = 9<br>
Output: [0, 1]<br>
Explanation: nums[0] + nums[1] = 2 + 7 = 9
</code>
<h4 style="margin-top: 20px;">Constraints:</h4>
<ul style="margin-left: 20px;">
<li>2 ≤ nums.length ≤ 10⁴</li>
<li>Only one valid answer exists</li>
<li>Can't use the same element twice</li>
</ul>
</div>
<div class="stats">
<div class="stat">
<div class="stat-value" id="testsRun">0</div>
<div>Tests Run</div>
</div>
<div class="stat">
<div class="stat-value" id="testsPassed">0</div>
<div>Passed</div>
</div>
<div class="stat">
<div class="stat-value" id="attempts">0</div>
<div>Attempts</div>
</div>
</div>
<div id="hints" style="margin-top: 20px;"></div>
</div>
<!-- Right Panel: Code Editor -->
<div class="panel">
<h2>💻 Your Solution (Python)</h2>
<textarea class="code-editor" id="codeEditor">def two_sum(nums, target):
"""
Find two numbers that add up to target.
Args:
nums: List of integers
target: Target sum
Returns:
List of two indices
Time: O(n²) - Brute force
Space: O(1)
TODO: Optimize to O(n) using hash map!
"""
# Your code here
passhtml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🚀 LeetCode Teacher - Two Sum (Instagram Likes)</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
color: white;
}
.container {
max-width: 1400px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.panel {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: 30px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
h1 {
font-size: 2.5em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.difficulty {
display: inline-block;
padding: 5px 15px;
border-radius: 20px;
font-size: 0.9em;
font-weight: bold;
margin-bottom: 20px;
}
.easy { background: #4CAF50; }
.medium { background: #FF9800; }
.hard { background: #F44336; }
.problem {
background: rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 10px;
margin: 20px 0;
line-height: 1.6;
}
.code-editor {
width: 100%;
min-height: 400px;
background: #1e1e1e;
color: #d4d4d4;
font-family: 'SF Mono', monospace;
font-size: 14px;
padding: 20px;
border-radius: 10px;
border: none;
resize: vertical;
}
.controls {
display: flex;
gap: 10px;
margin: 20px 0;
}
.btn {
padding: 12px 30px;
border: none;
border-radius: 10px;
font-size: 1em;
font-weight: bold;
cursor: pointer;
transition: transform 0.2s;
}
.btn-run {
background: linear-gradient(135deg, #4CAF50, #45a049);
color: white;
}
.btn-hint {
background: linear-gradient(135deg, #FF9800, #F57C00);
color: white;
}
.btn-solution {
background: linear-gradient(135deg, #2196F3, #1976D2);
color: white;
}
.btn:hover { transform: translateY(-2px); }
.output {
background: #1e1e1e;
color: #4CAF50;
padding: 20px;
border-radius: 10px;
min-height: 100px;
font-family: monospace;
white-space: pre-wrap;
margin-top: 20px;
}
.test-case {
background: rgba(255, 255, 255, 0.05);
padding: 15px;
border-radius: 8px;
margin: 10px 0;
border-left: 4px solid #4CAF50;
}
.test-failed {
border-left-color: #F44336;
}
.stats {
display: flex;
justify-content: space-around;
margin: 20px 0;
padding: 20px;
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
}
.stat {
text-align: center;
}
.stat-value {
font-size: 2em;
font-weight: bold;
color: #FFD700;
}
.pattern-badge {
display: inline-block;
background: rgba(255, 215, 0, 0.2);
color: #FFD700;
padding: 5px 15px;
border-radius: 15px;
margin: 5px;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="container">
<!-- Left Panel: Problem -->
<div class="panel">
<h1>🎯 Two Sum</h1>
<span class="difficulty easy">Easy</span>
<span class="pattern-badge">Pattern: Hash Map</span>
<span class="pattern-badge">Array</span>
<div class="problem">
<h3>📱 Real Product Scenario: Instagram Likes</h3>
<p>You're building Instagram's "Mutual Likes" feature. Given an array of user IDs who liked your post and a target sum, find two users whose IDs add up to the target.</p>
<h4 style="margin-top: 20px;">Problem:</h4>
<p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return indices of two numbers that add up to <code>target</code>.</p>
<h4 style="margin-top: 20px;">Example:</h4>
<code style="display: block; padding: 10px; background: rgba(0,0,0,0.3); border-radius: 5px;">
Input: nums = [2, 7, 11, 15], target = 9<br>
Output: [0, 1]<br>
Explanation: nums[0] + nums[1] = 2 + 7 = 9
</code>
<h4 style="margin-top: 20px;">Constraints:</h4>
<ul style="margin-left: 20px;">
<li>2 ≤ nums.length ≤ 10⁴</li>
<li>Only one valid answer exists</li>
<li>Can't use the same element twice</li>
</ul>
</div>
<div class="stats">
<div class="stat">
<div class="stat-value" id="testsRun">0</div>
<div>Tests Run</div>
</div>
<div class="stat">
<div class="stat-value" id="testsPassed">0</div>
<div>Passed</div>
</div>
<div class="stat">
<div class="stat-value" id="attempts">0</div>
<div>Attempts</div>
</div>
</div>
<div id="hints" style="margin-top: 20px;"></div>
</div>
<!-- Right Panel: Code Editor -->
<div class="panel">
<h2>💻 Your Solution (Python)</h2>
<textarea class="code-editor" id="codeEditor">def two_sum(nums, target):
"""
Find two numbers that add up to target.
Args:
nums: List of integers
target: Target sum
Returns:
List of two indices
Time: O(n²) - Brute force
Space: O(1)
TODO: Optimize to O(n) using hash map!
"""
# Your code here
passTest your solution
Test your solution
if name == "main":
# Example test
nums = [2, 7, 11, 15]
target = 9
result = two_sum(nums, target)
print(f"Result: {result}")
</textarea>
<div class="controls">
<button class="btn btn-run" onclick="runCode()">▶️ Run Tests</button>
<button class="btn btn-hint" onclick="getHint()">💡 Get Hint</button>
<button class="btn btn-solution" onclick="showSolution()">✨ Show Solution</button>
</div>
<div class="output" id="output">Click "Run Tests" to test your solution...</div>
</div>if name == "main":
# Example test
nums = [2, 7, 11, 15]
target = 9
result = two_sum(nums, target)
print(f"Result: {result}")
</textarea>
<div class="controls">
<button class="btn btn-run" onclick="runCode()">▶️ Run Tests</button>
<button class="btn btn-hint" onclick="getHint()">💡 Get Hint</button>
<button class="btn btn-solution" onclick="showSolution()">✨ Show Solution</button>
</div>
<div class="output" id="output">Click "Run Tests" to test your solution...</div>
</div>Test your solution
Test your solution
if name == "main":
nums = [2, 7, 11, 15]
target = 9
result = two_sum(nums, target)
print(f"Result: {result}") # [0, 1]`;
document.getElementById('codeEditor').value = solution;
alert('✨ Solution revealed! Study the pattern and try to implement it yourself next time.');
}Features:
- Interactive code editor
- Real-time test execution
- Progressive hints
- Visual test results
- Pattern badges
- Progress tracking
if name == "main":
nums = [2, 7, 11, 15]
target = 9
result = two_sum(nums, target)
print(f"Result: {result}") # [0, 1]`;
document.getElementById('codeEditor').value = solution;
alert('✨ Solution revealed! Study the pattern and try to implement it yourself next time.');
}功能特性:
- 交互式代码编辑器
- 实时测试执行
- 渐进式提示
- 可视化测试结果
- 模式标识徽章
- 进度跟踪
Language Support
语言支持
Python
Python
python
undefinedpython
undefinedHash Map pattern
Hash Map pattern
def two_sum(nums: List[int], target: int) -> List[int]:
seen = {}
for i, num in enumerate(nums):
complement = target - num
if complement in seen:
return [seen[complement], i]
seen[num] = i
return []
undefineddef two_sum(nums: List[int], target: int) -> List[int]:
seen = {}
for i, num in enumerate(nums):
complement = target - num
if complement in seen:
return [seen[complement], i]
seen[num] = i
return []
undefinedTypeScript
TypeScript
typescript
// Hash Map pattern
function twoSum(nums: number[], target: number): number[] {
const seen = new Map<number, number>();
for (let i = 0; i < nums.length; i++) {
const complement = target - nums[i];
if (seen.has(complement)) {
return [seen.get(complement)!, i];
}
seen.set(nums[i], i);
}
return [];
}typescript
// Hash Map pattern
function twoSum(nums: number[], target: number): number[] {
const seen = new Map<number, number>();
for (let i = 0; i < nums.length; i++) {
const complement = target - nums[i];
if (seen.has(complement)) {
return [seen.get(complement)!, i];
}
seen.set(nums[i], i);
}
return [];
}Kotlin
Kotlin
kotlin
// Hash Map pattern
fun twoSum(nums: IntArray, target: Int): IntArray {
val seen = mutableMapOf<Int, Int>()
nums.forEachIndexed { i, num ->
val complement = target - num
if (seen.containsKey(complement)) {
return intArrayOf(seen[complement]!!, i)
}
seen[num] = i
}
return intArrayOf()
}kotlin
// Hash Map pattern
fun twoSum(nums: IntArray, target: Int): IntArray {
val seen = mutableMapOf<Int, Int>()
nums.forEachIndexed { i, num ->
val complement = target - num
if (seen.containsKey(complement)) {
return intArrayOf(seen[complement]!!, i)
}
seen[num] = i
}
return intArrayOf()
}Swift
Swift
swift
// Hash Map pattern
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var seen = [Int: Int]()
for (i, num) in nums.enumerated() {
let complement = target - num
if let j = seen[complement] {
return [j, i]
}
seen[num] = i
}
return []
}swift
// Hash Map pattern
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var seen = [Int: Int]()
for (i, num) in nums.enumerated() {
let complement = target - num
if let j = seen[complement] {
return [j, i]
}
seen[num] = i
}
return []
}Problem Difficulty Progression
问题难度进阶
Level 1: Fundamentals (Easy)
第1级:基础(简单)
- Arrays and strings
- Basic hash maps
- Simple two pointers
- Linear search Goal: Build confidence, learn syntax
- 数组与字符串
- 基础哈希表
- 基础双指针
- 线性搜索 目标: 建立信心,学习语法
Level 2: Pattern Recognition (Easy-Medium)
第2级:模式识别(简单-中等)
- Sliding window
- Two pointers advanced
- Fast & slow pointers
- Basic trees Goal: Recognize patterns
- 滑动窗口
- 进阶双指针
- 快慢指针
- 基础树结构 目标: 识别问题模式
Level 3: Core Algorithms (Medium)
第3级:核心算法(中等)
- BFS and DFS
- Binary search variations
- Basic DP
- Heaps Goal: Master common patterns
- BFS与DFS
- 变种二分查找
- 基础动态规划
- 堆 目标: 掌握常见模式
Level 4: Advanced Techniques (Medium-Hard)
第4级:进阶技巧(中等-困难)
- Advanced DP
- Graph algorithms
- Backtracking
- Tries Goal: Handle complex scenarios
- 进阶动态规划
- 图算法
- 回溯法
- 字典树 目标: 处理复杂场景
Level 5: Interview Ready (Hard)
第5级:面试就绪(困难)
- System design integration
- Optimization problems
- Complex DP
- Advanced graphs Goal: Ace any interview
- 系统设计整合
- 优化问题
- 复杂动态规划
- 进阶图算法 目标: 通过任意面试
Learning Techniques Taught
教授的学习技巧
1. Pattern Recognition
1. 模式识别
See problem → Identify pattern → Apply template → Optimize看问题 → 识别模式 → 应用模板 → 优化2. Time/Space Analysis
2. 时间/空间复杂度分析
Always analyze:
- Time complexity: O(?)
- Space complexity: O(?)
- Can we do better?始终分析:
- 时间复杂度:O(?)
- 空间复杂度:O(?)
- 能否进一步优化?3. Test-Driven Development
3. 测试驱动开发
1. Read problem
2. Write test cases
3. Think of edge cases
4. Code solution
5. Run tests
6. Optimize1. 阅读问题
2. 编写测试用例
3. 考虑边界情况
4. 编写解决方案代码
5. 运行测试
6. 优化4. Optimization Journey
4. 优化流程
Brute Force → Identify bottleneck → Apply pattern → Optimize space暴力解法 → 识别瓶颈 → 应用模式 → 空间优化5. Interview Communication
5. 面试沟通技巧
- State assumptions
- Ask clarifying questions
- Think out loud
- Explain trade-offs
- Discuss alternatives- 说明假设条件
- 提出澄清问题
- 边思考边表达
- 解释权衡取舍
- 讨论替代方案Reference Materials
参考资料
All included in :
/references- patterns.md - 20 essential patterns with templates
- data_structures.md - Arrays, linked lists, trees, graphs, heaps
- problem_templates.md - Code templates for each pattern
- complexity_guide.md - Big O analysis and optimization
所有资料均位于目录下:
/references- patterns.md - 20种核心模式及模板
- data_structures.md - 数组、链表、树、图、堆
- problem_templates.md - 每种模式的代码模板
- complexity_guide.md - 大O分析与优化
Scripts
脚本
All in :
/scripts- generate_playground.sh - Create interactive coding environment
- generate_problem.sh - Generate specific problem type
- generate_session.sh - Create full practice session
所有脚本均位于目录下:
/scripts- generate_playground.sh - 创建交互式编码环境
- generate_problem.sh - 生成特定类型的问题
- generate_session.sh - 创建完整的练习会话
Best Practices
最佳实践
DO:
建议:
✅ Start with brute force, then optimize
✅ Write test cases first
✅ Analyze time/space complexity
✅ Practice the same pattern multiple times
✅ Explain your approach out loud
✅ Use real product context to remember
✅ Code in your target interview language
✅ 从暴力解法开始,再进行优化
✅ 先编写测试用例
✅ 分析时间/空间复杂度
✅ 多次练习同一模式
✅ 大声解释你的思路
✅ 借助真实产品背景记忆
✅ 使用目标面试语言编码
DON'T:
避免:
❌ Jump to optimal solution immediately
❌ Skip complexity analysis
❌ Memorize solutions without understanding
❌ Practice only easy problems
❌ Ignore edge cases
❌ Code in silence (practice explaining)
❌ Give up after one attempt
❌ 直接跳到最优解
❌ 跳过复杂度分析
❌ 死记硬背而不理解
❌ 只练习简单问题
❌ 忽略边界情况
❌ 沉默编码(练习解释)
❌ 一次尝试失败就放弃
Gamification
游戏化设计
Achievement System
成就系统
- 🌟 Pattern Master: Solve 10 problems with same pattern
- 🔥 Streak: 7 days in a row
- ⚡ Speed Demon: Solve in under 15 minutes
- 🎯 First Try: Pass all tests on first attempt
- 🏆 100 Club: Solve 100 problems
- 💎 Optimization: Improve O(n²) to O(n)
- 🧠 No Hints: Solve without any hints
- 🌟 模式大师:使用同一模式解决10个问题
- 🔥 连续练习:连续7天练习
- ⚡ 速通达人:15分钟内解决问题
- 🎯 一次通关:首次尝试通过所有测试
- 🏆 百题俱乐部:解决100个问题
- 💎 优化能手:将O(n²)优化为O(n)
- 🧠 无提示通关:不使用任何提示解决问题
Progress Tracking
进度跟踪
- Problems solved by difficulty
- Patterns mastered
- Languages practiced
- Success rate
- Average time per problem
- Streak counter
- 按难度划分的已解决问题数
- 已掌握的模式
- 练习过的语言
- 成功率
- 平均解题时间
- 连续练习天数
Summary
总结
This skill transforms technical interview prep by:
- Real Product Context - Learn through practical scenarios
- Pattern Recognition - Master the 20 essential patterns
- Multi-Language - Practice in Python, TypeScript, Kotlin, Swift
- Interactive - Code in browser with instant feedback
- Progressive - Build from fundamentals to expert
- Fun - Gamified with achievements and progress tracking
- Practical - Techniques that work in real interviews
"Master the patterns, ace the interview." 🚀
Usage: Ask for a specific pattern to practice, difficulty level, or real product scenario, and get an instant interactive coding playground!
该技能通过以下方式改变技术面试备考:
- 真实产品背景 - 通过实际场景学习
- 模式识别 - 掌握20种核心模式
- 多语言支持 - 在Python、TypeScript、Kotlin、Swift中练习
- 交互式体验 - 在浏览器中编码并获取即时反馈
- 渐进式进阶 - 从基础到专家逐步提升
- 趣味性 - 带有成就和进度跟踪的游戏化设计
- 实用性 - 适用于真实面试的技巧
“掌握模式,通过面试。” 🚀
使用方法: 要求练习特定模式、难度级别或真实产品场景,即可获取即时的交互式编码练习环境!