A TUI-based LeetCode Cheatsheet for Quick Problem Walkthroughs in Your Terminal.
leetsheet is a command-line application designed for developers who want a fast, offline, and focused way to review LeetCode problems. Instead of navigating browser tabs, get instant access to problem details, complexity analysis, whiteboard explanations, and multiple solution implementations directly in your terminal.
This isn't just another interview prep tool; it's a personal, offline-first, and blazingly fast cheatsheet. The goal is to minimize context switching and keep you in the "flow state" of your terminal. With a local JSON database of over 1200 problems, leetsheet provides a structured and comprehensive walkthrough for each, helping you internalize patterns and solutions without the distractions of the web.
Key information for each problem includes:
- Whiteboard Explanation: The high-level strategy and data structures involved.
- Dry Run: A step-by-step example to solidify understanding.
- Test Cases: Critical edge cases to consider.
- Complexity Analysis: Time and Space complexity with clear justifications.
- Dual Solutions: A manually crafted, commented solution and an AI-generated one for comparison.
- Instant Search: Filter through problems by title as you type.
- Tag-Based Filtering: Use
#tagsyntax (e.g.,#Array #HashTable) to find problems by topic. - Comprehensive Problem View: A clean, two-pane layout displaying problem details on the left and code solutions on the right.
- Toggleable Solutions: Instantly switch between the manually-written solution and an AI-generated one with the
ckey. - Vim-like Keybindings: Navigate lists and scroll content efficiently.
- Responsive TUI: The layout adapts to your terminal window size.
- Syntax Highlighting: Code solutions are beautifully highlighted for readability.
-- Offline First: All data is read from a local
problems.jsonfile, making it available anywhere, anytime.
You need to have Go (version 1.18 or newer) installed on your system.
# Check if Go is installed
go version-
Clone the repository:
git clone https://github.com/your-username/leetsheet.git
-
Navigate to the project directory:
cd leetsheet -
Get the data: Ensure you have the
problems.jsonfile in the root of the project directory. -
Build the binary:
go build
This will create an executable file named
leetsheetin the current directory. -
(Optional) Add to your PATH: For easy access from anywhere, move the binary to a directory in your system's PATH.
sudo mv leetsheet /usr/local/bin/
Simply run the executable from your terminal:
./leetsheetIf you moved it to your PATH, you can just run:
leetsheetThe application is fully keyboard-driven.
| View | Key | Action |
|---|---|---|
| Search | ctrl+c |
Quit the application |
| (Default) | / |
Start filtering (enter search mode) |
ctrl+j/k |
Navigate up/down the problem list | |
enter |
Select a problem and view its details | |
esc |
Clear the current filter/search | |
#tag |
Type # followed by a tag to filter |
|
| Problem | esc / / |
Go back to the search view |
| (Details) | tab |
Switch focus between left/right panes |
c |
Toggle between Manual and IA solution | |
↑/↓/j/k |
Scroll the content in the active pane |
All problem data is stored in problems.json. To add a new problem, you need to append a new JSON object to the array in this file.
Each problem object must follow this structure:
{
"title": "Your Problem Title",
"link": "https://leetcode.com/problems/your-problem-name/",
"keywords": ["#Tag1", "#Tag2"],
"complexity": {
"time": {
"notation": "O(N)",
"justification": "Explanation for time complexity."
},
"space": {
"notation": "O(1)",
"justification": "Explanation for space complexity."
}
},
"whiteboard": "A high-level explanation of the approach.",
"dry_run": "A step-by-step walk-through with an example.",
"test_cases": "A list of important edge cases to consider.",
"ia_solution": "The AI-generated code solution string.",
"manual_solution": "The manually written and commented code solution string."
}JSON requires strings to be properly escaped (e.g., newlines as \n, quotes as \"). To make it easy to add new code solutions, you can use the provided code_to_json.py utility script.
Usage:
-
(Optional) Install
pyperclipto automatically copy the output to your clipboard:pip install pyperclip
-
Paste your code: Open
code_to_json.pyand paste your multi-line code solution inside the triple quotes.import json import pyperclip # Paste your code between the triple quotes code = """class Solution: def yourCode(self, s: str) -> int: # Your implementation here return 0 """ # ... rest of the script
-
Run the script:
python code_to_json.py
-
Paste the output: The script will print a JSON-safe, single-line string. Paste this string as the value for
ia_solutionormanual_solutionin yourproblems.jsonfile. Ifpyperclipis installed, it will also be in your clipboard.
- Go - The core language.
- Bubble Tea - The TUI framework that makes this possible.
- Lipgloss - For beautiful, stylish terminal layouts.
- Glamour - For rendering Markdown and syntax-highlighted code blocks.
Distributed under the MIT License. See LICENSE for more information.
A huge thank you to the team at Charm for creating an amazing suite of tools for building beautiful TUIs.
