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.
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- codex-proxySkill
- executor-plansSkill
- executor-reviewsSkill
- git-conditional-identitiesSkill
- git-conventionsSkill
- oh-my-posh-setupSkill
- scheduling-codex-window-startsSkill
- skill-comparisonSkill
- windows-fe-dev-setupSkill
- ask-orchardSkill
- decide-before-doingSkill
- plan-to-docsSkill
- review-to-docsSkill
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
- Distinctive: line 20
Do not use this skill for:
- Distinctive: line 28
Before generating or revising a page, inspect:
- Distinctive: line 35
Use them as the default shell and behavior source.
- Distinctive: line 41
Keep the shell stable: header, theme toggle, core idea card, two-column desktop layout, left visualization, right code panel, bottom …
- Distinctive: line 42
Default to light mode and provide a visible dark-mode toggle.
- Distinctive: line 43
Keep the page one-screen-first.
- Very specific: line 45
Use one fixed page title format: LeetCode <problem-number> — <problem-title-cn> · <solution-keyword>.
- Distinctive: line 46
If the user provided code, explain that code instead of silently switching algorithms.
- Distinctive: line 48
Do not dynamically synchronize code-line highlighting during playback unless the user explicitly asks for it.
- Distinctive: line 52
If the user gives a LeetCode link, first try to fetch or read that exact URL with the tools available in the current environment.
- Very specific: line 53
If a leetcode.cn URL fails to fetch, try the corresponding non-cn LeetCode problem URL before giving up.
- Very specific: line 54
If direct fetching still fails, extract the problem slug from the URL and try a web search using leetcode <problem-slug> before giving up.
- Distinctive: line 55
If fetching is unavailable or incomplete after those attempts, ask for the core problem statement, constraints, and examples.
- Distinctive: line 56
If the user does not give code and the session supports back-and-forth interaction, ask which language the code panel should use.
- Distinctive: line 57
If the user does not give code and the request is effectively single-turn, explicitly state the fallback language before showing generated …
- Distinctive: line 58
If the user does not give code, choose one reasonable solution path and stay with it.
- Distinctive: line 59
If sample input/output is missing, create 1 to 3 small examples that reveal the algorithm's state changes.
- Distinctive: line 60
Do not silently rely on memory when link fetching failed.
- Very specific: line 75
Use slow, normal, and fast speed controls.
- Distinctive: line 79
Treat the data structure as the body and the algorithm as the motion.
- Distinctive: line 82
Start with one primary view.
- Very specific: line 86
Prefer descriptive variable names such as left, right, windowStart, currentNode, or nextNode.
- Very specific: line 87
Avoid cryptic abbreviations such as lo, hi, or tmp unless they are clearly standard and still readable.
- Distinctive: line 88
Keep generated reference implementations short and explanation-friendly.
≈ “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.
Files
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.htmlassets/shell/ui-contract.mdscripts/player-template.jsscripts/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.cnURL fails to fetch, try the corresponding non-cnLeetCode 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, ornextNode. - Avoid cryptic abbreviations such as
lo,hi, ortmpunless 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
- Gather the problem and chosen solution.
- Load the standard shell references before inventing any new structure.
- Identify the dominant data structure and choose the simplest matching visualization template.
- Derive the smallest example that reveals the algorithm's state changes.
- Break the solution into frames and map each frame to state, summary, and code highlights.
- Fill the standard shell instead of redesigning the page.
- 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
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
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.

