termleet
v1.0.0
Published
Print a random LeetCode problem with C++ solution directly in your terminal.
Maintainers
Readme
termleet
Revise LeetCode problems (with C++ solutions from walkccc) directly in your terminal — no browser required.
Preview
Installation
npm install -g termleetRequires Node.js 18 or later.
Usage
dsa # random problem + C++ solution
dsa --difficulty=medium # filter by difficulty (easy | medium | hard)
dsa --no-solution # show the problem onlyRun locally during development
# from repository root
npm install
npm install -g .
# run the globally linked CLI
dsaIf dsa can't find a walkccc solution after several attempts, it falls back to showing a LeetCode problem without the solution block so you can continue practicing.
dsa renders markdown directly in terminal using:
marked-terminalfor markdown structurecli-highlightfor C++ syntax highlighting
The output is markdown-friendly.
How it works
- Fetches the full LeetCode problem list from the public endpoint (
https://leetcode.com/api/problems/all/). - Picks a random free problem.
- Fetches problem details without login:
- First tries LeetCode's public GraphQL endpoint (
https://leetcode.com/graphql/). - If GraphQL is blocked/rate-limited/unavailable, falls back to the public problem page (
/problems/<slug>/description/) and extracts description data from embedded JSON.
- First tries LeetCode's public GraphQL endpoint (
- Fetches the corresponding C++ solution from the walkccc/LeetCode repository.
- If walkccc has no solution for the chosen problem, a different problem is tried automatically.
- During retries, unavailable slugs are tracked only in-memory for the current run (no local persistence file).
- Renders markdown to styled terminal output.
Development
# run unit tests (no network required)
npm test