How LeetCodeAnimation Categorizes Problems by Difficulty Level

The repository classifies every LeetCode problem by its official LeetCode difficulty tag—Easy, Medium, or Hard—storing these labels directly in Markdown documentation files.

The LeetCodeAnimation repository provides visual animations for LeetCode problems, organizing content to mirror the official LeetCode platform. Understanding how the repository categorizes problems by difficulty level helps developers quickly locate appropriate challenges for their skill level and filter content programmatically.

Where Difficulty Metadata is Stored

The difficulty classification system relies on author-provided metadata embedded in Markdown files. According to the repository structure, you can find the difficulty label in two primary locations.

Notes Files

Located in the notes/ directory, these files contain a specific line indicating the problem's difficulty. For example, in notes/LeetCode第9号问题:回文数.md, you will find:

题目难度为 Easy

Article Files

Each problem folder contains an Article subdirectory with a Markdown file that mirrors the notes content. For instance, 0094-Binary-Tree-Inorder-Traversal/Article/0094-Binary-Tree-Inorder-Traversal.md contains the same difficulty metadata as its corresponding notes file.

The Three Difficulty Levels

The repository follows LeetCode's standard three-tier classification system. Each level serves a distinct educational purpose within the animation collection.

Easy Problems

Easy problems typically serve as quick-run demos and introductory animations. These entries demonstrate fundamental algorithms and data structures with minimal complexity. An example is the Palindrome Number problem (notes/LeetCode第9号问题:回文数.md), marked as Easy to help beginners understand basic numerical algorithms.

Medium Problems

Medium difficulty problems involve slightly more complex visualizations, often incorporating two-pointer techniques, dynamic programming concepts, or tree traversals. The Binary Tree Inorder Traversal (notes/LeetCode第94号问题:二叉树的中序遍历.md) represents a Medium-level entry that demonstrates recursive and iterative tree processing methods.

Hard Problems

Hard problems showcase advanced visualizations including segment trees, backtracking algorithms, and complex dynamic programming solutions. These entries target experienced developers preparing for competitive programming or advanced technical interviews. The Merge K Sorted Lists problem (notes/LeetCode第23号问题:合并K个排序链表.md) exemplifies a Hard-level challenge requiring heap operations or divide-and-conquer strategies.

Programmatically Extracting Difficulty Levels

Developers can query the difficulty classification programmatically by scanning the Markdown files for the regex pattern 题目难度为\s+(Easy|Medium|Hard). This enables automated filtering, such as generating a curated list of Hard problems for intensive practice sessions.

The following Python script demonstrates how to extract all problems of a specific difficulty level from the repository:

import pathlib
import re

REPO_ROOT = pathlib.Path("/path/to/LeetCodeAnimation")
NOTE_GLOB = "**/notes/*.md"

def problems_by_difficulty(level: str) -> list[str]:
    """Return a list of markdown file paths whose difficulty matches `level`."""
    pattern = re.compile(rf"题目难度为\s+{level}", re.IGNORECASE)
    matches = []
    
    for md_file in REPO_ROOT.glob(NOTE_GLOB):
        try:
            text = md_file.read_text(encoding="utf-8")
        except Exception:
            continue
            
        if pattern.search(text):
            rel = md_file.relative_to(REPO_ROOT)
            url = f"https://github.com/MisterBooo/LeetCodeAnimation/blob/master/{rel}"
            matches.append(url)
            
    return matches

# Example: list all Medium-difficulty problems

if __name__ == "__main__":
    for url in problems_by_difficulty("Medium"):
        print(url)

Running this script outputs GitHub URLs for Medium-level problems such as:

  • https://github.com/MisterBooo/LeetCodeAnimation/blob/master/notes/LeetCode第94号问题:二叉树的中序遍历.md
  • https://github.com/MisterBooo/LeetCodeAnimation/blob/master/notes/LeetCode第92号问题:反转链表II.md

Summary

  • The LeetCodeAnimation repository categorizes problems by difficulty using the official LeetCode tags: Easy, Medium, and Hard.
  • Difficulty metadata resides in Markdown files within the notes/ directory and corresponding Article/ subfolders, marked by the line 题目难度为 [Level].
  • Easy problems serve introductory purposes, Medium problems cover intermediate algorithms like tree traversals, and Hard problems address advanced concepts such as segment trees and complex dynamic programming.
  • Developers can programmatically filter problems by difficulty using regex pattern matching against the repository's Markdown files.

Frequently Asked Questions

How does LeetCodeAnimation determine the difficulty level of a problem?

The repository does not calculate or infer difficulty levels. Instead, it uses the official LeetCode difficulty tag assigned to each problem on the LeetCode platform. These labels are manually maintained by the repository authors in the Markdown documentation to ensure consistency with the source platform.

Where can I find the difficulty classification in the repository files?

You can locate the difficulty metadata in two primary locations: the notes/ directory containing summary Markdown files, and the Article/ subfolders within each problem's directory. Look for the Chinese text 题目难度为 followed by the English difficulty level (Easy, Medium, or Hard).

Can I filter problems by difficulty level programmatically?

Yes, you can extract problems by difficulty using simple regex pattern matching. Scan the Markdown files for the pattern 题目难度为\s+(Easy|Medium|Hard) to identify files matching your target difficulty. This approach enables you to generate custom study lists or filter content for specific practice sessions.

Are the difficulty levels in LeetCodeAnimation different from the official LeetCode website?

No, the difficulty levels remain identical to those on the official LeetCode platform. The repository maintains synchronization with LeetCode's official tags to ensure that users practice problems with the same difficulty ratings they would encounter on the actual platform. This consistency helps developers accurately gauge their preparation level for technical interviews.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →