[!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:
- Go to Settings → Plugins → Marketplace
- Search for “LeetCode Editor”
- Click Install
Alternatively, you can download it directly from the JetBrains Marketplace
Configuring the Plugin
After installation, configure the plugin with these recommended settings:
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
- Open the LeetCode tool window in IntelliJ IDEA (typically on the right sidebar)
- Click the Login button
- Enter your LeetCode credentials in the popup window
Solving Problems
- Open the LeetCode tool window
- Use the 🔍 Filter panel to find problems by difficulty, tags, or search term
- Double-click a problem to open it in the editor
- The plugin will create a new file using your template structure
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
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: