For online LeetCode users who wish to work on and save code offline, this script reads a URL with the specific problem and:
- Queries problem information from LeetCode (LeetCode uses GraphQL as its API query language)
- Creates a local Python file with the appropriate file name if file does not already exist
- Formats and populates the problem information
- Launches the new file to be worked on (Windows function only)
Usage:
- In the terminal, navigate to the directory where you intend to generate the new Python file
- Acquire the full URL of the LeetCode problem to use as argument (ex: 'https://leetcode.com/problems/same-tree/' or 'https://leetcode.com/problems/same-tree/description/')
- Run main.py (ex:
python main.py https://leetcode.com/problems/same-tree/description/
)