- dot_omp: agent config/keybindings/mcp/themes/commands + loop defs, goals, run-loop.sh; dotstate config.yml symlink materialized; dbs, logs, sessions, memories, blobs, caches, .env (secret), and managed-skills excluded - .chezmoiexternal.toml: prdlk/nvim as git-repo external — no refreshPeriod + ff-only pull, local checkout wins over remote - yazi plugins: vendored source copies dropped (target-ignored already); package.toml is the manifest, installed via run_onchange ya pkg install hook; stale piper/easyjump pins bumped to match live content - herdr: plugins/github checkout, logs, session.json, .bak, release-notes dropped from sync (herdr-managed machine state)
3.2 KiB
description
| description |
|---|
| Add super-simple line-by-line comments to a LeetCode solution file |
Add beginner-level line-by-line comments to the LeetCode solution file at: $1
Rules
-
Read the file first. It follows the standard on-disk format:
- A
/* ... */header block containing problem number, title, difficulty, URL, description, examples, and constraints - A JSDoc
@param/@returnblock - The solution function(s)
- A
-
Never touch the header block or JSDoc block. Preserve them byte-for-byte.
-
Never change the code. Do not rename variables, reformat logic, alter whitespace inside expressions, or "improve" anything. Comments only. The file must produce an identical AST after your edit.
-
Comment style — explain as if to a complete beginner who has never programmed:
- One comment line (or short block) ABOVE each meaningful line/statement
- Use plain everyday language and physical metaphors:
- object/map → "box" ("Create an empty box to count how many times each number appears")
- increment → "add 1 to its count"
(freq[x] || 0) + 1→ "If we already saw this number, add 1 to its count. If we never saw it before, start counting from 1"- sort comparator → spell out the rule in words ("put the letter that appears MORE times first; if tied, alphabetical order")
- return → say WHAT is being returned and WHY in plain words
- Explain the WHY, not just the WHAT ("so the next bigger numbers know there are more smaller ones")
- Inline comments (
// ...at end of line) are fine for short trailing clarifications like.join('')→ "glue the sorted letters back into a string" - No jargon without immediate translation: if you must say "index", follow with "(its position)"
-
Add a section banner above the solution function in this exact style:
// ============================================ // <problem number>. <problem title> // ============================================Pull the number and title from the header block.
-
Multiple solutions in one file: comment every one of them, each with its own banner (append "– Approach 2" etc. to the banner title).
-
Extra instructions (if provided after the file path): $@
-
After editing, print a one-line confirmation: file path + number of comment lines added. Nothing else.
Example transformation
Input body:
var smallerNumbersThanCurrent = function (nums) {
const freq = {};
for (let x of nums) freq[x] = (freq[x] || 0) + 1;
return nums.map((x) => smaller[x]);
};
Output body:
// ============================================
// 1365. How Many Numbers Are Smaller Than the Current Number
// ============================================
var smallerNumbersThanCurrent = function (nums) {
// Create an empty box to store how many times each number appears
const freq = {};
// Go through every number in the list one by one
// If we already saw this number, add 1 to its count
// If we never saw it before, start counting from 1
for (let x of nums) freq[x] = (freq[x] || 0) + 1;
// Go through the original list and replace each number
// with "how many numbers are smaller than it"
return nums.map((x) => smaller[x]);
};