The Leetcode Contest Helper Extension is a tool designed to streamline the coding experience during LeetCode contests. It eliminates the manual effort of writing additional code for input/output handling, allowing you to focus on solving problems efficiently inside your favorite code editor.
- Automatic Code Download: Quickly download code during contests or for individual problems.
- Code Templates: Support for custom code templates and main functions.
- Language Support: Extensive support for C++, with the option to choose other languages.
- Friend Rankings: Add friends and view their live rankings in contests.
- Install the extension from the Web Store.
- Navigate to the LeetCode contest or individual problem page.
- Open the extension and click the "Download" button to fetch the code.
- Customize code templates and main functions as needed.
- Support for questions of type QUERY is not available.
- Currently, extensive support is provided for C++, with options for other languages.
This generated code takes input from {fileName_input}.txt
and outputs to {fileName_output}.txt
.
To incorporate support for additional programming languages, follow these steps within the src/codes/{language}/mapping.js
file:
-
Update Mapping Functions:
- Locate and modify the
get_template()
,get_body()
, andget_main()
functions in themapping.js
file for the respective language.
- Locate and modify the
-
Function Parameters:
- Each function receives three props:
content
: Contains the question and examples.codeSnippet
: The code present in the LeetCode code editor.metaData
: Contains input and output data types.
- Each function receives three props:
-
Code Structure:
Template
: consists of utility functions aiding problem-solving.Body
: Comprises the content in comments followed by the code snippet. Include helper functions that read any type of input and print any type of output in format provided by LeetCode.Main
: Should iterate over test cases, utilize helper functions, or define them within the main function. Ensure it interacts with the Solution class and displays output as done by LeetCode.
-
Reference Existing Implementation:
- Refer to the existing
mapping.js
files in thesrc/codes/cpp/mapping.js
, for better understanding.
- Refer to the existing
-
Data Types:
- The extension currently recognizes the following data types:
string
,integer
,boolean
,double
,long
,char
,ListNode
,TreeNode
,void
, andfloat.
- For arrays, they are represented as either using
{dataType}[]
notation, or usinglist<>
syntax.- For example, a 2D array of strings can be denoted as
string[][]
orlist<list<string>>
.
- For example, a 2D array of strings can be denoted as
- The extension currently recognizes the following data types:
public
├── content-script.js
├── images
│ └── icon.png
└── manifest.json
src
├── App.css
├── App.jsx
├── codes
│ ├── erlang
│ ├── kotlin
│ ├── python
│ ├── rust
│ ├── bash
│ ├── python3
│ ├── scala
│ ├── c
│ ├── mssql
│ ├── pythondata
│ ├── swift
│ ├── cpp
│ ├── golang
│ ├── mysql
│ ├── pythonml
│ ├── typescript
│ ├── csharp
│ ├── html
│ ├── oraclesql
│ ├── racket
│ ├── react
│ ├── ruby
│ ├── exampleProblem.json
│ ├── exportMappings.js
│ └── languages.json
├── components
│ ├── codeComponent.jsx
│ ├── downloader.jsx
│ ├── languageSelector.jsx
│ └── utils
│ ├── backgroundDesign.css
│ ├── backgroundDesign.jsx
│ ├── getDataGraphql.jsx
│ ├── getDataRest.jsx
│ └── startDownload.jsx
├── pages
│ ├── friends.jsx
│ └── home.jsx
└── store
├──Store.jsx
└── stateStore.jsx
-
public
Directorycontent-script.js
: Contains functions for injecting scripts and DOM elements into leetcode to fetch friends' rankings and add friends.images
: Directory housing the project logo (icon.png
).manifest.json
: Configuration file for the extension.
-
src
DirectoryApp.css
andApp.jsx
: Responsible for styling and serving as the main component for the extension iframe.
2.1.
src/codes
Directory- Subdirectories for each supported programming language, each containing
mapping.js
and a test file. exampleProblem.json
: Holds example problem data.exportMappings.js
: File for exporting language mappings.languages.json
: Configuration file listing information about supported languages.
2.2.
src/components
DirectorycodeComponent.jsx
,downloader.jsx
,languageSelector.jsx
: React components handling various functionalities.
2.3.
components/utils
Directory- Utility components for the extension.
backgroundDesign.css
andbackgroundDesign.jsx
: Manage styling and functionality for the extension background.getDataGraphql.jsx
andgetDataRest.jsx
: Functions for fetching data using GraphQL and REST, respectively.startDownload.jsx
: Handles the functionality to initiate code download.
-
src/pages
Directoryfriends.jsx
andhome.jsx
: React components for the 'Friends' and 'Home' pages.
-
src/store
Directory- Store.jsx
and
stateStore.jsx`: Components managing extension state and a Zustand global state.
- Store.jsx
Feel free to contribute and enhance language support or add new features.
Happy Coding! 🚀