LeetCli
A CLI tool that generates random LeetCode problems with skeleton code in your preferred programming language.
Features
- Interactive topic selection (Arrays, Linked Lists, Graphs, Trees, Tries, DP, etc.)
- Multiple programming language support (Rust, Python, JavaScript, Java, C++, Go, TypeScript)
- AI-generated problems with proper skeleton code and test cases
- Automatic file creation in
problems/
directory - Customizable AI models for different speed/quality preferences
- Command line interface with help and options
Setup
-
Get a Gemini API key from Google AI Studio
-
Build and run:
The tool will ask for your Gemini API key on first run and save it securely in ~/.leetcli_api_key
for future use.
You can also set it as an environment variable to skip the prompt entirely:
Usage
Basic Usage
On first run, you'll be prompted to select a default difficulty level which will be saved for future use.
Interactive Difficulty Selection
Shows a dropdown menu to select difficulty level and updates your saved preference.
Direct Difficulty Setting
Sets difficulty directly and updates your saved preference.
Combined Options
List Available Options
Help
Available Models
gemini-2.5-flash-lite
(default) - Fastest model, good for quick problem generationgemini-2.0-flash-exp
- Experimental fast model with latest featuresgemini-1.5-flash-latest
- Stable fast model, reliable performancegemini-1.5-pro-latest
- More capable but slower, better for complex problemsgemini-pro
- Older stable model
Available Difficulty Levels
easy
- Simple problems with basic algorithms and data structuresmedium
- Moderate complexity with common algorithmshard
- Complex problems with advanced algorithms and optimization
Persistent Preferences
The tool saves your preferences locally:
- API Key:
~/.leetcli_api_key
- Difficulty:
~/.leetcli_difficulty
Preferences are automatically updated when you use command line arguments.
API Key Priority
The tool checks for your API key in this order:
GEMINI_API_KEY
environment variable- Saved key file (
~/.leetcli_api_key
) - Interactive prompt (saves for future use)
Example Output
First Run
>> LeetCli
Subsequent Runs
>> LeetCli
Interactive Difficulty Change
>> LeetCli
Generated files include:
- Complete problem description with examples
- Code skeleton with proper function signatures
- Test cases to verify your implementation
- All necessary imports and boilerplate
Command Line Options
)
Examples
# Generate problem with saved preferences
# First time setup - will ask for difficulty preference
# Interactive difficulty selection
# Direct difficulty setting
# Generate easy problem with fast model
# Generate hard problem with pro model
# List all available options