Get the FREE Ultimate OpenClaw Setup Guide →

leetcode-problem-fetcher

Scanned
npx machina-cli add skill a5c-ai/babysitter/leetcode-problem-fetcher --openclaw
Files (1)
SKILL.md
5.6 KB

leetcode-problem-fetcher

A specialized skill for fetching and parsing LeetCode problems with complete metadata, suitable for competitive programming practice, interview preparation, and algorithm learning workflows.

Purpose

Extract comprehensive problem data from LeetCode including:

  • Problem statements and descriptions
  • Input/output constraints and formats
  • Test cases and hidden constraints
  • Problem difficulty, tags, and acceptance rate
  • Related problems and pattern tags
  • Hints and solution approaches

Capabilities

Core Features

  1. Problem Retrieval

    • Fetch problems by title slug (URL-friendly name)
    • Retrieve daily challenge problems
    • Search problems by category, tags, difficulty, or keywords
    • Access premium problem alternatives when available
  2. Metadata Extraction

    • Difficulty level (Easy, Medium, Hard)
    • Acceptance rate and submission statistics
    • Problem tags and categories
    • Related problems and similar questions
    • Company tags (when available)
  3. Content Parsing

    • Problem description in markdown format
    • Input/output examples with explanations
    • Constraints and edge cases
    • Follow-up questions and optimizations
    • Code templates for multiple languages
  4. User Data Access

    • User profile and statistics
    • Contest ranking and history
    • Submission history and solutions
    • Progress tracking across problem sets

Integration Options

MCP Server (Recommended)

# Install LeetCode MCP Server by jinzcdev
claude mcp add-json "leetcode" '{"type":"stdio","command":"npx","args":["-y","@jinzcdev/leetcode-mcp-server","--site","global"]}'

Available MCP Tools:

  • get_daily_challenge - Fetch daily LeetCode challenge
  • get_problem - Retrieve problem by titleSlug
  • search_problems - Filter by category, tags, difficulty, keywords
  • get_user_profile - Access user data
  • get_user_contest_ranking - Track contest performance

Direct API Integration

// GraphQL endpoint for LeetCode
const LEETCODE_GRAPHQL = 'https://leetcode.com/graphql';

// Query for problem details
const problemQuery = `
  query getProblem($titleSlug: String!) {
    question(titleSlug: $titleSlug) {
      questionId
      title
      titleSlug
      content
      difficulty
      topicTags { name slug }
      hints
      sampleTestCase
      codeSnippets { lang code }
      stats
    }
  }
`;

Browser Extension

Competitive Companion - Parses problems from LeetCode and 115+ other online judges:

Usage

Fetch a Problem

# Using MCP Server
leetcode get_problem --titleSlug "two-sum"

# Output includes:
# - Problem title and description
# - Difficulty and acceptance rate
# - Topic tags
# - Examples and constraints
# - Code templates

Search Problems

# Search by difficulty and tags
leetcode search_problems --difficulty MEDIUM --tags "dynamic-programming,array"

# Search by keyword
leetcode search_problems --keyword "substring"

Get Daily Challenge

# Fetch today's daily challenge
leetcode get_daily_challenge

Output Schema

{
  "problem": {
    "id": "string",
    "title": "string",
    "titleSlug": "string",
    "difficulty": "Easy|Medium|Hard",
    "acceptanceRate": "number",
    "description": "string (markdown)",
    "constraints": ["string"],
    "examples": [
      {
        "input": "string",
        "output": "string",
        "explanation": "string"
      }
    ],
    "hints": ["string"],
    "topicTags": ["string"],
    "similarQuestions": ["string"],
    "codeTemplates": {
      "python3": "string",
      "cpp": "string",
      "java": "string"
    }
  },
  "metadata": {
    "fetchedAt": "ISO8601 timestamp",
    "source": "leetcode.com|leetcode.cn"
  }
}

Integration with Processes

This skill enhances the following processes:

  • leetcode-problem-solving - Core problem-solving workflow
  • pattern-recognition - Identifying algorithmic patterns
  • faang-interview-prep - FAANG interview preparation

References

Error Handling

ErrorCauseResolution
PROBLEM_NOT_FOUNDInvalid titleSlugVerify problem URL or slug
RATE_LIMITEDToo many requestsImplement exponential backoff
AUTH_REQUIREDPremium problemUse alternative or authenticate
NETWORK_ERRORConnection failedCheck network, retry with backoff

Best Practices

  1. Caching: Cache problem data to reduce API calls
  2. Rate Limiting: Respect LeetCode's rate limits (use delays between requests)
  3. Error Handling: Gracefully handle premium/locked problems
  4. Offline Mode: Store fetched problems for offline practice
  5. Data Freshness: Re-fetch periodically for updated statistics

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/algorithms-optimization/skills/leetcode-problem-fetcher/SKILL.mdView on GitHub

Overview

leetcode-problem-fetcher pulls problem statements, constraints, samples, hints, difficulty, and statistics from LeetCode. It also surfaces tags, related problems, and acceptance rates to support practice, interview prep, and algorithm learning. It supports MCP server integration or direct API access for comprehensive data retrieval.

How This Skill Works

The skill queries LeetCode via MCP server or GraphQL/REST endpoints to retrieve a problem by titleSlug or daily challenge. It then parses content into a structured representation and extracts metadata such as difficulty, acceptance rate, tags, constraints, and sample test cases, plus related problems.

When to Use It

  • When you need a complete problem profile for practice sets
  • To fetch today’s daily LeetCode challenge
  • To filter problems by difficulty, category, tags, or keywords
  • To obtain constraints, samples, hints, and solution prompts
  • To seed automated practice dashboards or course content

Quick Start

  1. Step 1: Install or access the MCP server or enable direct GraphQL access to LeetCode
  2. Step 2: Retrieve a problem with leetcode get_problem --titleSlug two-sum
  3. Step 3: Render the problem description, constraints, examples, hints, and metadata for your UI or notes

Best Practices

  • Use precise titleSlug with get_problem for deterministic results
  • Cache results between runs to reduce API calls
  • Cross-check constraints and samples against the parsed content
  • Leverage related problems to study patterns and difficulty progression
  • Respect API rate limits and check for premium content when available

Example Use Cases

  • Assemble a weekly practice list of 10 medium problems with DP and graph tags
  • Automate daily challenge intake for a learning journal
  • Seed a coding course with problems and hints for students
  • Create a personalized challenge set using user tag preferences
  • Compare related problems to study technique like sliding window or two pointers

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers