Algo Sensei

repository·main·Indexed 41 days ago

https://github.com/karanb192/algo-sensei

An intelligent Claude Code skill and mentor designed to help developers master Data Structures & Algorithms (DSA) and LeetCode problems. It features specialized modes including Tutor, Hint, Review, Interview, and Pattern Mapper to teach underlying patterns and thinking processes rather than providing direct solutions.

Tokens
9.8K
Snippets
8
Records
42
Agent score
54%

What's inside Algo Sensei

  1. Overview of Algo Sensei features and modes

    main

    Algo Sensei is an intelligent mentor designed to teach Data Structures & Algorithms (DSA) through guidance rather than just providing solutions. It uses several specialized modes to adapt to your learning needs:

    • Tutor Mode: Focuses on building intuition through concept explanations and ASCII art diagrams.
    • Hint Mode: Uses a 5-level progressive system to guide you toward a solution without spoiling it immediately.
    • Review Mode: Provides comprehensive feedback on your code, including complexity analysis and optimization opportunities.
    • Interview Mode: Simulates a professional technical interview with roleplay and a performance rubric.
    • Pattern Mapper Mode: Teaches you how to recognize algorithmic patterns (like Sliding Window, DP, or Monotonic Stack) by analyzing problem characteristics.
  2. How hint calibration works in Interview Mode

    main

    To maintain realism, the AI uses a tiered hint system. It avoids giving away the answer immediately, simulating how real interviewers assist candidates.

    • Stuck for 2-3 min: The AI provides a gentle nudge (e.g., "Let me give you a hint - think about [concept]").
    • Still stuck: The AI provides a more specific hint (e.g., "What if you used a [data structure] to track [something]?").
    • Completely stuck: The AI outlines the high-level approach (e.g., "Let me outline the approach: [steps]. Can you implement this?").

    Note: Top companies expect candidates to unstick themselves with minimal hints. Too many hints result in a weaker evaluation signal.

  3. How Hint Mode works

    main

    Hint Mode is a pedagogical mode designed to guide users to solutions using the Socratic Method. Instead of providing direct answers or code, it uses a 5-level progressive hint framework to build problem-solving intuition and pattern recognition. The goal is to help users discover the solution themselves through guided questioning.

    The 5-Level Hint Framework

    1. Level 1: Observation & Clarification: Focus on input structure, constraints, and simple cases (e.g., "What do you notice about the input structure?").
    2. Level 2: Pattern Recognition: Guide toward identifying the problem category (e.g., "Does this remind you of any classic problem?").
    3. Level 3: Approach Direction: Point toward a technique without naming it (e.g., "What if you kept track of what you've seen before?").
    4. Level 4: Specific Technique: Explicitly name the pattern or data structure (e.g., "This is a sliding-window problem").
    5. Level 5: Pseudocode Skeleton: A last resort providing a high-level logic structure (e.g., function solve(input): // Step 1...).
    function solve(input):
        // Step 1: [What to do]
        // Step 2: [What to do]
        // Step 3: [What to do]
        // Step 4: Return result
  4. Complexity Analysis Standards in Algo Sensei

    main

    When Algo Sensei provides solutions or reviews code, it adheres to a strict complexity analysis standard. Every analysis must include:

    • Time Complexity: Detailed breakdown of Best, Average, and Worst case scenarios.
    • Space Complexity: Identification of the auxiliary space used by the algorithm.
    • Trade-offs: An explanation of why the chosen approach was used versus potential alternatives.
  5. Problem to Pattern Mapping Guide

    main

    Use this guide to identify which algorithmic pattern to apply based on the problem description.

    • "Contiguous subarray with condition" $\rightarrow$ Sliding Window
    • "Pairs in sorted array" $\rightarrow$ Two Pointers
    • "All combinations/permutations" $\rightarrow$ Backtracking
    • "Optimization (max/min)" $\rightarrow$ Dynamic Programming or Greedy
    • "Shortest path" $\rightarrow$ BFS (unweighted) or Dijkstra (weighted)
    • "Is there a cycle?" $\rightarrow$ DFS or Union Find
    • "Top K elements" $\rightarrow$ Heap
    • "Range queries" $\rightarrow$ Segment Tree or Binary Indexed Tree
    • "Search in sorted" $\rightarrow$ Binary Search
    • "Parentheses matching" $\rightarrow$ Stack
    • "Tree level-order" $\rightarrow$ BFS (queue)
    • "Tree paths" $\rightarrow$ DFS (recursion)
  6. How Algo Sensei modes work and how to trigger them

    main

    Algo Sensei uses 'Intelligence Routing' to automatically detect your learning needs based on your request. It switches between five specialized modes to provide the most effective assistance. You can trigger these modes by using specific keywords or intent in your prompts:

    • TUTOR MODE: For learning foundations. Trigger by asking to "explain", "teach me", "how does X work", or saying "I don't understand".
    • HINT MODE: For progressive guidance without spoilers. Trigger by saying "give me a hint", "I'm stuck", "don't tell me the answer", or requesting "progressive hints".
    • REVIEW MODE: For code optimization and feedback. Trigger by sharing code and asking for "review", "feedback", "is this optimal?", or requesting "complexity analysis".
    • INTERVIEW MODE: For mock technical interviews. Trigger by asking for a "mock interview", "practice interview", or asking the agent to "be the interviewer".
    • PATTERN MAPPER MODE: For identifying algorithmic techniques. Trigger by asking "what pattern is this?", "which technique to use", or requesting "similar problems".
  7. How Tutor Mode works

    main

    Tutor Mode is a specialized learning mode designed to build foundational understanding of Data Structures and Algorithms (DSA) through guided learning rather than direct lecturing. It follows a structured teaching framework that prioritizes assessing user knowledge, building from fundamentals, and using incremental complexity.

    The Teaching Framework

    1. Assess Understanding: Gauge current knowledge by asking about prior experience with specific concepts or identifying specific points of confusion.
    2. Build from Fundamentals: Use simple definitions, everyday analogies, and visual representations (like ASCII art) to establish a base.
    3. Problem Breakdown: When tackling a problem, the mode follows a 6-step structure:
      • Restate in Plain English: Remove jargon and focus on core tasks.
      • Walk Through Examples: Trace logic manually with simple examples and intermediate states.
      • Identify the Pattern: Name the pattern (e.g., Two Pointers) and explain why it fits.
      • Build Intuition: Explain the "aha!" moment and efficiency.
      • Code Together: Move from pseudocode to step-by-step implementation.
      • Complexity Analysis: Walk through time and space complexity line-by-line.

    Session Progression

    A typical session follows this lifecycle:

    1. Understand the gap (Identify confusion)
    2. Build foundation (Solidify prerequisites)
    3. Explain concept (Structured explanation)
    4. Apply knowledge (Collaborative examples)
    5. Independent practice (Suggest similar problems)
    6. Check mastery (Verify understanding via questioning)
    Problem: [Problem Name]
    
    🎯 Core Task:
    [Explain in simple terms]
    
    📝 Example Walkthrough:
    Input: [example]
    Let's trace through this step-by-step:
    1. [step]
    2. [step]
    Output: [result]
    
    🔍 Pattern Recognition:
    This is a [pattern] problem because [reason]
    
    💡 Key Insight:
    [The "aha!" moment that makes this click]
    
    🏗️ Building the Solution:
    Pseudocode:
    [high-level logic]
    
    Python Implementation:
    [code with detailed comments]
    
    ⏱️ Complexity:
    Time: O(?) because [explanation]
    Space: O(?) because [explanation]
    
    🎓 Practice Problems:
    Try these similar problems:
    - [LeetCode #XXX]
    - [LeetCode #YYY]
  8. Optimize solutions by problem type

    main

    Review Mode applies specific optimization strategies based on the category of the problem you are solving:

    Array/String Problems

    • Look for unnecessary nested loops (replace with Hash Maps).
    • Look for multiple passes (aim for a single pass).
    • Look for extra arrays (aim for in-place operations).

    Tree/Graph Problems

    • Evaluate traversal efficiency (BFS vs DFS).
    • Check for redundant visits (use a visited set).
    • Check for missing base cases (prevent stack overflow).

    Dynamic Programming

    • Check for missing memoization in top-down approaches.
    • Look for space optimization (e.g., converting 2D DP to 1D).
    • Check if recursion can be converted to an iterative DP table.

    Sorting/Searching

    • Check if a specialized sort (counting/bucket) is applicable.
    • Check if linear search can be replaced by binary search on sorted data.
    • Check if sorting is even necessary (use heaps or hash maps instead).
  9. How Pattern Mapper Mode works

    main

    Pattern Mapper Mode is a specialized mode in Algo Sensei designed to train users in algorithmic pattern recognition rather than just providing solutions. Instead of giving the answer, the mode guides users through a structured framework to identify patterns (like Sliding Window, DP, or Two Pointers) based on problem characteristics, signal keywords, and constraints.

    The Mental Model for Pattern Recognition:

    1. Analyze Input/Output: Determine data structure types, sorted properties, and whether the goal is optimization (max/min), counting, or generation.
    2. Identify Signal Keywords: Look for phrases like "contiguous subarray" (Sliding Window) or "shortest path" (BFS/Dijkstra).
    3. Pattern Matching: Use leading questions to narrow down the approach (e.g., "Can you skip elements?" or "Are subproblems overlapping?").
    4. Pattern Application: Once identified, the mode provides the pattern name, the reasoning, a code template, and similar problems.
  10. Time Complexity Hierarchy and Examples

    main

    The hierarchy of time complexity from best (fastest) to worst (slowest) is:

    O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2^n) < O(n!)

    Common Examples:

    • O(1): Array access, hash map lookup
    • O(log n): Binary search, balanced tree operations
    • O(n): Linear search, array traversal
    • O(n log n): Merge sort, heap sort, quick sort (average)
    • O(n²): Bubble sort, nested loops
    • O(2^n): Recursive fibonacci, subsets
    • O(n!): Permutations
    O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2^n) < O(n!)
  11. How Review Mode works

    main

    Review Mode is a specialized mode in Algo Sensei designed to provide thorough, constructive code reviews for algorithmic solutions. It focuses on four key pillars: Correctness, Complexity, Code Quality, and Interview Readiness.

    When you use Review Mode, the system follows a structured framework to evaluate your code:

    1. Initial Assessment: A quick scan for compilation and basic problem-solving capability.
    2. Correctness Analysis: Tracing logic and testing against edge cases (empty input, single elements, duplicates, etc.).
    3. Complexity Analysis: Line-by-line evaluation of Time and Space complexity, comparing your solution to the optimal approach.
    4. Code Quality Review: Assessing variable naming, structure, comments, and redundancy.
    5. Interview Readiness: Evaluating how easy the solution is to explain and discuss trade-offs.

    You can request different levels of depth:

    • Quick Review: Validation of correctness, complexity, and a rating.
    • Standard Review (Default): Uses a full template with detailed explanations and code snippets.
    • Deep Review: Includes alternative approaches, line-by-line walkthroughs, and practice recommendations.
  12. Custom Hint Strategies by Problem Type

    main

    Use these specific progression paths depending on the problem category:

    Array/String Problems

    1. "What pattern do you see in the elements?"
    2. "Could you solve this in one pass?"
    3. "What if you used two pointers/hash map?"

    Tree Problems

    1. "Think about how you'd traverse the tree."
    2. "What information do you need from child nodes?"
    3. "This is a [DFS/BFS/recursion] problem."

    Dynamic Programming

    1. "Can you solve this for a smaller input?"
    2. "What are the overlapping subproblems?"
    3. "Define what your DP state represents."
    4. "What's your recurrence relation?"

    Graph Problems

    1. "How can you represent this as a graph?"
    2. "What type of traversal fits this problem?"
    3. "Do you need to track visited nodes?"

    Greedy Problems

    1. "What choice would you make at each step?"
    2. "Can you prove this locally optimal choice is globally optimal?"
    3. "What if you sort the input first?"