DEV Community

Samanuai
Samanuai

Posted on

I Built a LeetCode CLI That Tracks Your Solve Time and Saves Solution Versions

The Problem

If you've ever grinded LeetCode, you know the pain:

  • Constantly switching between browser and editor
  • No way to track how long problems actually take you
  • Losing your brute-force solution after optimizing
  • No timer to simulate real interview pressure

I solved all of this by building leetcode-cli β€” a full LeetCode workflow that runs entirely in your terminal.

Demo


What It Does

πŸ“‹ List & Solve Problems

leetcode list -d medium        # Filter by difficulty
leetcode show 1                # View problem
leetcode pick 1                # Generate solution file
leetcode test 1                # Test locally
leetcode submit 1              # Submit to LeetCode
Enter fullscreen mode Exit fullscreen mode

Files are auto-organized by difficulty and category:

leetcode/
β”œβ”€β”€ Easy/
β”‚   └── Array/
β”‚       └── 1.two-sum.java
└── Medium/
    └── String/
        └── 3.longest-substring.java
Enter fullscreen mode Exit fullscreen mode

⏱️ Interview Timer

Practice under real pressure with difficulty-based defaults:

leetcode timer 1               # Easy: 20min, Medium: 40min, Hard: 60min
leetcode timer 1 -m 30         # Custom: 30 minutes
leetcode timer --stats         # See your solve time history
Enter fullscreen mode Exit fullscreen mode

The timer tracks your times so you can measure improvement over weeks.

πŸ“Έ Solution Snapshots

Save different approaches and compare them:

leetcode snapshot save 1 "brute-force"
# ... optimize your solution ...
leetcode snapshot save 1 "optimized"
leetcode snapshot diff 1 1 2   # Compare the two
leetcode snapshot restore 1 brute-force  # Go back if needed
Enter fullscreen mode Exit fullscreen mode

Never lose a working solution again.

πŸ‘₯ Collaborative Coding

Practice with a partner using room codes:

# Person 1
leetcode collab host 1         # Creates room: ABC123

# Person 2
leetcode collab join ABC123

# Both solve, then compare
leetcode collab compare
Enter fullscreen mode Exit fullscreen mode

Great for mock interviews with friends.

πŸ“ Workspaces

Keep different contexts separate:

leetcode workspace create interview -w ~/lc-interview
leetcode workspace create daily -w ~/lc-daily
leetcode workspace use interview
Enter fullscreen mode Exit fullscreen mode

Each workspace has its own config, timer history, and snapshots.

πŸ”„ Git Sync

Auto-backup solutions to GitHub:

leetcode config --repo https://github.com/you/leetcode-solutions.git
leetcode sync
Enter fullscreen mode Exit fullscreen mode

Installation

npm install -g @night-slayer18/leetcode-cli
Enter fullscreen mode Exit fullscreen mode

Or with Docker:

docker pull nightslayer/leetcode-cli:latest
Enter fullscreen mode Exit fullscreen mode

Quick Start

leetcode login     # Paste your LeetCode cookies
leetcode daily     # Get today's challenge
leetcode pick 1    # Start solving
Enter fullscreen mode Exit fullscreen mode

Why I Built This

I was tired of:

  1. Opening Chrome just to see the problem
  2. Not knowing if I was getting faster
  3. Losing my first approach after refactoring

Now my entire LeetCode workflow lives in the terminal, and I have data on my improvement.


Links


If this helps your LeetCode grind, give it a ⭐ on GitHub!

What features would you want to see next? Let me know in the comments πŸ‘‡

Top comments (0)