npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leetcode-local-runner

v1.0.3

Published

Auto-run LeetCode Java solutions locally without modifying Solution.java

Readme

LeetCode Local Runner

NPM Version Node Version License: MIT

A cross-platform CLI tool to automatically compile and run LeetCode Java solutions locally without modifying your Solution.java file.

Write code like you do on LeetCode → get instant results on your machine.


Features

  • File Watching: Automatically detects changes in any Solution.java file.
  • Code Generation: Automatically generates a runnable Main.java file.
  • Smart Parsing: Detects the solution method name and its parameters.
  • Classpath-Free: Embeds your Solution class into a Main class to avoid classpath issues.
  • Helper Classes: Automatically includes common helper classes like ListNode and TreeNode.
  • Cross-Platform: Works on Windows, Ubuntu, and macOS.
  • Stable Polling: Uses a reliable polling mechanism to watch for file changes.

Installation

You can install the tool globally via npm, which is the recommended approach.

npm install -g leetcode-local-runner

Alternatively, you can install it as a development dependency in your project:

npm install --save-dev leetcode-local-runner

Usage

  1. Open your terminal or command prompt.

  2. Navigate to the directory containing your LeetCode problem folders (each with a Solution.java).

  3. Run the following command:

    leetcode-watch
  4. The tool will start watching for file modifications. Every time you save a Solution.java file, it will automatically:

    • Generate a new Main.java in the same directory.
    • Compile and run Main.java to show you the output.

Now you can focus on writing your solution and see the results instantly!


Why This Tool Exists

The official VS Code LeetCode extension, with over 1.2 million downloads, is excellent for:

  • Browsing problems
  • Writing solutions
  • Submitting to LeetCode

But it does not provide a stable local Java runner without:

  • Editing Solution.java
  • Writing custom main() methods
  • Fighting classpath / package issues

LeetCode Local Runner solves exactly that, while staying 100% compatible with the extension.


Required VS Code Configuration

To ensure zero conflicts between the extension and this runner, add the following to your settings.json:

{
  "leetcode.hint.configWebviewMarkdown": false,
  "editor.inlineSuggest.edits.allowCodeShifting": "never",
  "leetcode.hint.commentDescription": false,
  "leetcode.hint.commandShortcut": false,
  "leetcode.filePath": {
    "default": {
      "folder": "${id}.${name}",
      "filename": "Solution.${ext}"
    }
  }
}

Why These Settings Matter

| Setting | Reason | | :--- | :--- | | Solution.java filename | Required for automatic detection | | Stable folder naming | Ensures watcher works correctly | | Disable inline hints | Prevents file rewrite / cursor shifts | | No markdown hints | Avoids unintended code injection |

With this configuration, both tools coexist perfectly.


How It Works

The script works by parsing your Solution.java file to understand its structure. It then generates a complete, runnable Main.java file that wraps your code.

For example, if your Solution.java is:

// Solution.java
class Solution {
    public int[] twoSum(int[] nums, int target) {
        // Your code here...
    }
}

The tool will generate a Main.java file like this:

// Main.java (Auto-generated)
import java.util.*;

public class Main {
    // Helper classes like ListNode or TreeNode are automatically injected here if needed.

    static class Solution {
        // Your entire Solution.java code is placed here.
        public int[] twoSum(int[] nums, int target) {
            // Your code here...
        }
    }

    public static void main(String[] args) {
        Solution sol = new Solution();
        
        // Dummy data is used to call your method.
        // (Note: The dummy data is hardcoded in the script for now)
        int[] nums = {2, 7, 11, 15};
        int target = 9;
        int[] result = sol.twoSum(nums, target);
        
        System.out.println(Arrays.toString(result));
    }
}

This design means you don't have to worry about managing classpaths or writing a main method just for testing.


Contributing

Contributions are welcome! Please feel free to open a Pull Request or an Issue to discuss any changes.


License

This project is licensed under the MIT License.