agentleFS
OrchardxyzOrchardxyz/agent-skills/skills/deprecated/visualizing-leetcode-solutions/SKILL.md

visualizing-leetcode-solutions

Skill0 starsChanged 4 months agoMITView on GitHub

Use when turning a LeetCode problem and one chosen solution into a step-by-step HTML walkthrough, especially when code alone is hard to follow and the user would benefit from frame-by-frame visualization.

The file

Show its rules and text

We split this skill into the rules it gives an agent

24 rules. About 0 are common, 18 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not use this skill for:

    line 20
  2. Distinctive:

    Before generating or revising a page, inspect:

    line 28
  3. Distinctive:

    Use them as the default shell and behavior source.

    line 35
  4. Distinctive:

    Keep the shell stable: header, theme toggle, core idea card, two-column desktop layout, left visualization, right code panel, bottom …

    line 41
  5. Distinctive:

    Default to light mode and provide a visible dark-mode toggle.

    line 42
  6. Distinctive:

    Keep the page one-screen-first.

    line 43
  7. Very specific:

    Use one fixed page title format: LeetCode <problem-number> — <problem-title-cn> · <solution-keyword>.

    line 45
  8. Distinctive:

    If the user provided code, explain that code instead of silently switching algorithms.

    line 46
  9. Distinctive:

    Do not dynamically synchronize code-line highlighting during playback unless the user explicitly asks for it.

    line 48
  10. Distinctive:

    If the user gives a LeetCode link, first try to fetch or read that exact URL with the tools available in the current environment.

    line 52
  11. Very specific:

    If a leetcode.cn URL fails to fetch, try the corresponding non-cn LeetCode problem URL before giving up.

    line 53
  12. Very specific:

    If direct fetching still fails, extract the problem slug from the URL and try a web search using leetcode <problem-slug> before giving up.

    line 54
  13. Distinctive:

    If fetching is unavailable or incomplete after those attempts, ask for the core problem statement, constraints, and examples.

    line 55
  14. Distinctive:

    If the user does not give code and the session supports back-and-forth interaction, ask which language the code panel should use.

    line 56
  15. Distinctive:

    If the user does not give code and the request is effectively single-turn, explicitly state the fallback language before showing generated …

    line 57
  16. Distinctive:

    If the user does not give code, choose one reasonable solution path and stay with it.

    line 58
  17. Distinctive:

    If sample input/output is missing, create 1 to 3 small examples that reveal the algorithm's state changes.

    line 59
  18. Distinctive:

    Do not silently rely on memory when link fetching failed.

    line 60
  19. Very specific:

    Use slow, normal, and fast speed controls.

    line 75
  20. Distinctive:

    Treat the data structure as the body and the algorithm as the motion.

    line 79
  21. Distinctive:

    Start with one primary view.

    line 82
  22. Very specific:

    Prefer descriptive variable names such as left, right, windowStart, currentNode, or nextNode.

    line 86
  23. Very specific:

    Avoid cryptic abbreviations such as lo, hi, or tmp unless they are clearly standard and still readable.

    line 87
  24. Distinctive:

    Keep generated reference implementations short and explanation-friendly.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Visualizing LeetCode Solutions

Overview

Turn one LeetCode problem and one chosen solution into a compact, single-file HTML walkthrough.

This skill uses one fixed visual shell derived from the rotate-array example. Do not redesign the page for each problem. Replace the content layer, frame data, and only the minimum visualization details required by the data structure.

When to Use

  • The user wants a LeetCode problem explained visually instead of only reading code
  • The user wants a simple HTML artifact with playback controls
  • The user provides a LeetCode link, title, problem text, code, or some combination of them

Do not use this skill for:

  • Comparing multiple algorithms for the same problem
  • Designing a new frontend product or plugin shell
  • Building a heavy animation system before the explanation structure is clear

Required References

Before generating or revising a page, inspect:

  • assets/shell/base-layout.html
  • assets/shell/ui-contract.md
  • scripts/player-template.js
  • scripts/code-panel-template.js

Use them as the default shell and behavior source.

Non-Negotiables

  • Reuse the canonical rotate-array shell. Do not invent a brand-new page layout for each problem.
  • Produce one single-file HTML document.
  • Keep the shell stable: header, theme toggle, core idea card, two-column desktop layout, left visualization, right code panel, bottom controls.
  • Default to light mode and provide a visible dark-mode toggle.
  • Keep the page one-screen-first. Long visualization content and long code should scroll inside their own panels.
  • Preserve code indentation exactly. Render code from source lines with a whitespace-preserving container or line-by-line textContent.
  • Use one fixed page title format: LeetCode <problem-number> — <problem-title-cn> · <solution-keyword>.
  • If the user provided code, explain that code instead of silently switching algorithms.
  • The right panel should support two modes: real code and pseudocode. Default to real code.
  • Do not dynamically synchronize code-line highlighting during playback unless the user explicitly asks for it.

Input Rules

  • If the user gives a LeetCode link, first try to fetch or read that exact URL with the tools available in the current environment.
  • If a leetcode.cn URL fails to fetch, try the corresponding non-cn LeetCode problem URL before giving up.
  • If direct fetching still fails, extract the problem slug from the URL and try a web search using leetcode <problem-slug> before giving up.
  • If fetching is unavailable or incomplete after those attempts, ask for the core problem statement, constraints, and examples.
  • If the user does not give code and the session supports back-and-forth interaction, ask which language the code panel should use.
  • If the user does not give code and the request is effectively single-turn, explicitly state the fallback language before showing generated code.
  • If the user does not give code, choose one reasonable solution path and stay with it.
  • If sample input/output is missing, create 1 to 3 small examples that reveal the algorithm's state changes.
  • Do not silently rely on memory when link fetching failed. Only continue from known problem knowledge after making that fallback explicit.

Output Contract

The page must include:

  • Problem title and short summary
  • Core idea in 2 to 5 sentences
  • Left panel for state visualization
  • Right panel for code
  • Code mode toggle for 真实代码 and 伪代码
  • Step explanation tied to the current frame
  • Controls for play, pause, previous, next, restart, and speed
  • Frame indicator such as Step 3 / 12

Use slow, normal, and fast speed controls.

Visualization Rules

  • Treat the data structure as the body and the algorithm as the motion.
  • Each frame should make clear: what is visible now, what operation is happening, which code lines matter, and why the step moves the solution forward.
  • Choose the simplest template that matches the dominant structure: arrays/strings, linked lists, stacks/queues, trees, heaps, graphs, or hash tables.
  • Start with one primary view. Add a second synchronized view only when it truly clarifies the algorithm.

Code Rules

  • Prefer descriptive variable names such as left, right, windowStart, currentNode, or nextNode.
  • Avoid cryptic abbreviations such as lo, hi, or tmp unless they are clearly standard and still readable.
  • Keep generated reference implementations short and explanation-friendly.
  • Provide a short pseudocode view that mirrors the real solution path without language-specific syntax noise.

Workflow

  1. Gather the problem and chosen solution.
  2. Load the standard shell references before inventing any new structure.
  3. Identify the dominant data structure and choose the simplest matching visualization template.
  4. Derive the smallest example that reveals the algorithm's state changes.
  5. Break the solution into frames and map each frame to state, summary, and code highlights.
  6. Fill the standard shell instead of redesigning the page.
  7. Generate a single-file HTML walkthrough.

Common Mistakes

  • Rebuilding the UI for each problem instead of reusing the canonical shell
  • Letting code overflow break the layout instead of making the code panel scroll internally
  • Losing indentation when generating code
  • Skipping language confirmation in an interactive session
  • Explaining a different algorithm than the user's code

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.