Public API¶
The main public method is get_problem(num: int) -> dict
update_problem_listing()
only needs to be ran once (or when new problems are added to leetcode)
main.py¶
Main entry point for the program.
Usage:
u
– update the problem index
c
– count number of problems
<num>
– get problem info for <num>
problem_info.py¶
Gets problem information from leetcode. Stores problem num, title, slug, question id in sqlite3 database.
- get_problem(num: int) dict | None [source]¶
Gets problem info for problem number
Searches local sqlite3 database for problem slug and question id, uses those to query leetcode GraphQL API for problem info and synced code.
Returned fields include:
num (int): leetcode problem number title (str): problem title slug (str): problem slug difficulty (str): problem difficulty description (str): problem description examples (list[dict]): problem examples constraints (list[str]): problem constraints code_snippet (str): problem code snippet code (str): synced code func (dict): function info
- Parameters:
num (int) – leetcode problem number
- Returns:
problem info fields
- Return type:
dict
- update_problem_listing()[source]¶
Fetches all leetcode problems title, slug, and question id and stores in local sqlite3 database.