This repository provides a step-by-step guide to setting up LeetCode coding environment in Visual Studio Code (VSCode).
Before you start, make sure you have:
- Visual Studio Code installed.
- Node.js installed.
- A LeetCode account.
- Open VSCode.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or pressing
Ctrl+Shift+X
. - Search for and install the following extensions:
- LeetCode: This extension integrates with the LeetCode platform to help you manage and submit your code.
- Python (or the appropriate language extension you plan to use): For coding in Python, C++, Java, etc.
- Code Runner: Allows you to run code snippets quickly.
- After installing the LeetCode extension, open the Command Palette with
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Type
LeetCode: Sign In
and follow the prompts to log in to your LeetCode account. - Configure any additional settings if needed by going to the VSCode settings (
File
>Preferences
>Settings
) and searching forLeetCode
.
- Open a terminal in VSCode by selecting
Terminal
>New Terminal
from the menu. - Clone the LeetCode repository (or create a new one) by using the following command:
git clone https://github.com/your-username/your-repo-name.git
- Navigate to the cloned repository:
cd your-repo-name
-
Open a LeetCode Problem:
- Open the Command Palette by pressing
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Type
LeetCode: Search Problem
and select it from the list. - Choose a problem from your LeetCode account to open it in the editor.
- Open the Command Palette by pressing
-
Write Your Solution:
- In the editor, write your code to solve the problem.
-
Test Your Code:
- Open the Command Palette by pressing
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Type
LeetCode: Test
and select it from the list. - The extension will run your code against the test cases provided by LeetCode and display the results in the Output pane or inline in the editor.
- Open the Command Palette by pressing
-
Submit Your Code:
- Open the Command Palette by pressing
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Type
LeetCode: Submit
and select it from the list. - Confirm the submission when prompted. The extension will submit your solution to LeetCode.
- Open the Command Palette by pressing
By following these steps, you can efficiently test and submit your LeetCode solutions directly from VSCode.
If you'd like to contribute to this guide or have suggestions for improvement, please fork the repository and create a pull request.
This repository is licensed under the MIT License.