[!NOTE]

You can find an example repository on my GitHub: yhao3/leetcode-in-intellij-idea.

Setting Up LeetCode in IntelliJ IDEA

This guide walks you through setting up and using the LeetCode Editor plugin in IntelliJ IDEA, allowing you to practice coding problems directly in IntelliJ IDEA.

Installing the LeetCode Plugin

Start by installing the LeetCode Editor plugin from the JetBrains Marketplace:

  1. Go to SettingsPluginsMarketplace
  2. Search for “LeetCode Editor”
  3. Click Install

Alternatively, you can download it directly from the JetBrains Marketplace

Configuring the Plugin

After installation, configure the plugin with these recommended settings:

LeetCode plugin configuration

1. Set the TempFilePath

This is where your LeetCode solutions will be saved:

/Users/haoyang/intellij-workspace/leetcode-101/src/main/java/com/github/yhao3

[!IMPORTANT]

Replace this with your own project path.

2. Enable Custom Templates

Code FileName Template

Use this format for organized file naming:

no$!velocityTool.leftPadZeros(${question.frontendQuestionId}, 5)/$!velocityTool.camelCaseName(${question.titleSlug})

This generates nicely formatted filenames like: no00001/TwoSum.java

Code Template

package com.github.yhao3.leetcode.editor.en.no$!velocityTool.leftPadZeros(${question.frontendQuestionId}, 5);

${question.content}
${question.code}

public class $!velocityTool.camelCaseName(${question.titleSlug}) {}

[!NOTE]

The package name must match your TempFilePath setting with leetcode.editor.en appended to the end.

3. Additional Settings

  • Check Multiline: Enables proper multiline comments for problem descriptions
  • Check HtmlContent: Preserves formatted HTML content in your Java files

Logging into LeetCode

  1. Open the LeetCode tool window in IntelliJ IDEA (typically on the right sidebar)
  2. Click the Login button
  3. Enter your LeetCode credentials in the popup window

LeetCode login screen

Solving Problems

  1. Open the LeetCode tool window
  2. Use the 🔍 Filter panel to find problems by difficulty, tags, or search term
  3. Double-click a problem to open it in the editor
  4. The plugin will create a new file using your template structure

LeetCode filter panel

Starting a LeetCode problem

Testing and Submitting Solutions

For each problem, you’ll have these options:

  • Run Code: Test your solution with sample inputs
  • Submit: Submit your solution for official evaluation

Run and submit buttons

The results will appear directly in the tool window, showing execution time, memory usage, and test case results.

Benefits of Using the Plugin

  • Code in a familiar environment with all your IntelliJ IDEA features
  • Track your progress and submission history
  • Organize solutions in a structured project
  • Practice with the same tools you use for everyday development
  • Solve LeetCode problems at work

Resources

For more information and updates, refer to: