JetBrains Plugin for LeetCode
Relationship Between the Plugin and Our Site
The solutions and ideas in the plugin are explanations of articles and exercises on our site, serving as auxiliary tools. They are not mandatory, so choose based on your needs.
Some readers prefer solving problems in an editor or IDE rather than on a webpage for easier coding and debugging. Therefore, I developed and maintained plugins for various platforms to meet this need, allowing readers to view problem explanations, visualizations, and problem lists from our site within the plugin.
The JetBrains plugin allows solving LeetCode problems in all JetBrains IDEs (e.g., Intellij, Pycharm). You can directly view our solution explanations and visual panels, and it integrates the Quick Mastery Directory and Beginner's Directory for convenient review:

Installation Method
The full name of my plugin is "LeetCode with labuladong". Search for the keyword "labuladong" in the JetBrains IDE plugin store to download:

If you cannot find the plugin, it might be a network issue. You can follow the instructions on the JetBrains plugin website to download and install:
https://plugins.jetbrains.com/plugin/19317-leetcode-with-labuladong
This plugin is developed based on the open-source plugin LeetCode Editor (thanks to the open-source author @shuzijun):
https://github.com/shuzijun/leetcode-editor/
User Guide
Below is an introduction to the basic use of this plugin and the supplementary problem-solving features of our site.
Log in to LeetCode Account
After installing the plugin, a plugin icon will appear in the sidebar. Click the settings button and configure as shown below:

1️⃣ Click the settings button to enter the settings page.
2️⃣ Choose the login site, which can be the English LeetCode or the Chinese 力扣.
3️⃣ Set the programming language you wish to use.
4️⃣ Set the storage path for the problem code files.
5️⃣ Click the OK button after setting up.
6️⃣ Click the login button.
After clicking the login button, a dialog will prompt you to enter a cookie. If your login site is the English LeetCode, enter the cookie for leetcode.com. If it's the Chinese 力扣, enter the cookie for leetcode.cn:

To obtain the cookie for Chinese 力扣 leetcode.cn, open the 力扣 website https://leetcode.cn in a browser, ensure you're logged in, open the developer tools (press F12 in Chrome), and copy the cookie value:

1️⃣ ~ 2️⃣ Open the Chinese 力扣 website https://leetcode.cn and ensure you are logged into your account.
3️⃣ Open the developer tools (F12 in Chrome) and click the Network tab.
4️⃣ ~ 6️⃣ Refresh the page, click the first request, and view the Headers of the request, which contain a Cookie field.
7️⃣ Select the entire cookie string and right-click to copy.
The method for obtaining the cookie for the English LeetCode is similar; just open the English LeetCode website https://leetcode.com and repeat the above steps. This will not be repeated here.
Paste the cookie into the plugin and click login. You should then be able to successfully log into your 力扣/LeetCode account within the plugin and start solving problems.
Local Code Debugging
Highlighting the functionality of custom code templates can maximize the advantages of an IDE:
- Automatically add a
main
function to code files. - Automatically rename files/classes to the English name of the problem for better organization and searchability.
- Automatically declare built-in data structures like
TreeNode
andListNode
from LeetCode. - Utilize IDE's auto-completion and debug features.
For detailed configuration methods and project examples, see here.
In addition to the basic features of the LeetCode Editor, I've added many practical functions, briefly introduced below.
Solution/Idea Aid for Problem Solving
After successful login, problems with my solutions or ideas will be marked with ✨:

Clicking on the details page of a problem marked with ✨ will display "labuladong Solution" and "labuladong Idea":

Code Image Annotation
The code in "labuladong Idea" supports direct copying, and a light bulb icon in the code will pop up images to aid in understanding the code logic:

Algorithm Visualization Panel
When expanding the "labuladong Idea," an interactive algorithm visualization panel appears below the solution code to help understand the algorithm's execution process:

For specific functions of the visualization panel, please refer to Algorithm Visualization Panel Introduction.
Switching to English for International Users
The content of the plugin's solutions/ideas/visualization panel is in Chinese by default. International users who need to switch to English can change the Language option to English in the plugin's settings page.
Update Method
JetBrains IDEs will automatically detect updates and notify you when a new version is available. It is recommended to update to the latest version promptly for the best experience.
Changelog
See the detailed Jetbrain Plugin Changelog.
Unlocking Site Explanations and Problem Sets in the Plugin
You can explore our site's problem lists and solution ideas within the plugin. However, you need to subscribe to the site and follow the method described at the bottom of the Subscription Page to manually refresh data.
Common Issue Solutions
How to Debug Code Locally
To use the custom code template feature, please carefully refer to the "Local Code Debugging" section in the guide above.
Chinese Characters Display as Gibberish?
This issue typically does not occur with newer versions of IDEs and operating systems. If it does happen, you can refer to this post to change the IDE's encoding to utf-8.
Why Does the Problem Page Suddenly Go Blank?
Has your IDE been in use for a long period? Only heavy users of the IDE encounter this bug, which is challenging to diagnose. It is likely caused by some cache/internal configuration issues during the IDE upgrade process. A simple solution is to download the latest version of the IDE from the official website and install it over the existing IDE (don't worry, your existing configurations won't be overwritten). This should resolve all issues.
Why Are There No ✨ Marks on the Problem List?
If the problem list still lacks the ✨ marks after logging in, you can manually refresh the labuladong solution data by clicking the website logo icon on the far right of the toolbar:

After waiting for about ten seconds, you should see a notification indicating "Manual refresh of labuladong data successful," and the ✨ marks will appear.
If there is still no response and no error message, it is likely a network issue. Try disabling your proxy or switching networks and then refresh the data again.
Why Are There ✨ Marks but No Solution or Thought Buttons?
If the data fetch is successful, but the problem detail page lacks the "labuladong Solution" and "labuladong Thought" buttons, it is because the IDE's file system cache has not been refreshed.
You can try manually clearing the IDE's cache and restarting the IDE:

Code Does Not Auto-Complete or Correct?
Code completion and correction are fundamental features of an IDE and are not related to plugins. If these features are not working, it is usually because your IDE is not properly configured or your code file is not recognized by the IDE.
For example, in the Go language, you need to add package main
at the top of your code file for it to be recognized by the Goland IDE. You can use the "Local Debugging Code" feature introduced earlier to automatically add this line.
Similarly, for Java files, they need to be part of a Java project to be recognized by the IDE. You can modify the plugin settings by setting TempFilePath
to your project path and configuring Code Template to automatically add the package name. This way, the code file will be saved in the project, and the IDE will recognize it and provide code completion.
No Code Submission Button?
Older plugin versions might have this issue. Please ensure you are using the latest version of the plugin. Generally, when you move your mouse to the code editing area, buttons for submission, testing, etc., should appear in the upper right corner.
Additionally, right-clicking in the code file will also display options for submission, testing, and other functions.
Bug Reporting
You can create an issue on GitHub to report problems: