leetcode-teacher

安装量: 137
排名: #6312

安装

npx skills add https://github.com/jamesrochabrun/skills --skill leetcode-teacher

LeetCode Teacher

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 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 Core Principles 1. Pattern-First Learning Recognize problem patterns Apply proven templates Build intuition through practice Master one pattern at a time 2. Real Product Context Instagram feed ranking Uber trip matching Netflix recommendation Slack message search Amazon inventory management 3. Progressive Difficulty Start with fundamentals Build complexity gradually Unlock advanced patterns Track skill progression 4. Multi-Language Mastery Practice in your target language Compare implementations Learn language-specific tricks Interview in any language 5. Interactive Learning 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) space

  1. 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) space

  1. 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) space

Tree & Graph Patterns

  1. 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)

  1. 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)

  1. 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) space

  1. 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) space

  1. 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) space

Dynamic Programming Patterns

  1. 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 space

  1. 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 space

  1. 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 optimized

  1. Longest Common Subsequence

Pattern: Compare two sequences Use when: Diff tools, edit distance Example: "Find similar code snippets" Complexity: O(m * n) time and space

Other Essential Patterns

  1. 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) space

  1. 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) space

  1. 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) space

  1. Backtracking

Pattern: Try all possibilities with pruning Use when: Generate permutations, combinations Example: "Generate all valid parentheses combinations" Complexity: Varies, often exponential

  1. Union Find

Pattern: Track connected components Use when: Network connectivity, grouping Example: "Find connected friend groups" Complexity: O(α(n)) amortized per operation

  1. 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) space

  1. Monotonic Stack

Pattern: Maintain increasing/decreasing stack Use when: Next greater/smaller element Example: "Stock price span calculation" Complexity: O(n) time, O(n) space

  1. 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, Swift

Slack: Unread Messages

Real Scenario: Find first unread message in channel Pattern: Linear Search with Flag Data Structure: Array Teaches: Early termination

Uber: Calculate Fare

Real Scenario: Compute trip cost based on distance and time Pattern: Simple Calculation Data Structure: Numbers Teaches: Math operations, rounding

Medium 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 sorting

Amazon: Inventory Management

Real Scenario: Find products running low in stock Pattern: Filtering with Threshold Data Structure: Array + HashMap Teaches: Multi-criteria filtering

Twitter: Trending Hashtags

Real Scenario: Find most used hashtags in time window Pattern: Sliding Window + Frequency Count Data Structure: Queue + HashMap Teaches: Time-based window management

LinkedIn: Degrees of Connection

Real Scenario: Find connection path between two users Pattern: BFS Data Structure: Graph (Adjacency List) Teaches: Shortest path, level tracking

Hard 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 intervals

Spotify: Playlist Shuffle

Real Scenario: True random shuffle avoiding artist repetition Pattern: Modified Fisher-Yates Data Structure: Array Teaches: Randomization with constraints

GitHub: Merge Conflict Resolution

Real Scenario: Find longest common subsequence in files Pattern: Dynamic Programming (LCS) Data Structure: 2D Array Teaches: DP state definition, optimization

Airbnb: 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

Interactive Playground Example Python Playground

🚀 LeetCode Teacher - Two Sum (Instagram Likes)

🎯 Two Sum

Easy Pattern: Hash Map Array

📱 Real Product Scenario: Instagram Likes

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.

Problem:

Given an array of integers nums and an integer target, return indices of two numbers that add up to target.

Example:

Input: nums = [2, 7, 11, 15], target = 9
Output: [0, 1]
Explanation: nums[0] + nums[1] = 2 + 7 = 9

Constraints:

  • 2 ≤ nums.length ≤ 10⁴
  • Only one valid answer exists
  • Can't use the same element twice
0
Tests Run
0
Passed
0
Attempts

💻 Your Solution (Python)

Click "Run Tests" to test your solution...

Features:

Interactive code editor Real-time test execution Progressive hints Visual test results Pattern badges Progress tracking Language Support Python

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 []

TypeScript // Hash Map pattern function twoSum(nums: number[], target: number): number[] { const seen = new Map();

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 // Hash Map pattern fun twoSum(nums: IntArray, target: Int): IntArray { val seen = mutableMapOf()

nums.forEachIndexed { i, num ->
    val complement = target - num

    if (seen.containsKey(complement)) {
        return intArrayOf(seen[complement]!!, i)
    }

    seen[num] = i
}

return intArrayOf()

}

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) Arrays and strings Basic hash maps Simple two pointers Linear search Goal: Build confidence, learn syntax Level 2: Pattern Recognition (Easy-Medium) Sliding window Two pointers advanced Fast & slow pointers Basic trees Goal: Recognize patterns Level 3: Core Algorithms (Medium) BFS and DFS Binary search variations Basic DP Heaps Goal: Master common patterns Level 4: Advanced Techniques (Medium-Hard) Advanced DP Graph algorithms Backtracking Tries Goal: Handle complex scenarios Level 5: Interview Ready (Hard) System design integration Optimization problems Complex DP Advanced graphs Goal: Ace any interview Learning Techniques Taught 1. Pattern Recognition See problem → Identify pattern → Apply template → Optimize

  1. Time/Space Analysis Always analyze:
  2. Time complexity: O(?)
  3. Space complexity: O(?)
  4. Can we do better?

  5. Test-Driven Development

  6. Read problem
  7. Write test cases
  8. Think of edge cases
  9. Code solution
  10. Run tests
  11. Optimize

  12. Optimization Journey Brute Force → Identify bottleneck → Apply pattern → Optimize space

  13. Interview Communication

  14. State assumptions
  15. Ask clarifying questions
  16. Think out loud
  17. Explain trade-offs
  18. 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 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 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 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!

返回排行榜