Python Templates for LeetCode

My personal summerized LeetCode Python templates.

Python Twitter Follow LeetCode user xy-li LeetCode user xy-li

Star me on GitHub:

This website is still updating slowly due to some difficulties in my academic events in school. If you have any suggestion of:

  • New algorithm/programming topics (e.g., how about create a template about trie?)

  • More and better problem examples for existing topics

  • Proof-reading

Please comment on the corresponding pages, and your comment will be kept as a comment for a GitHub issue permanently. Besides, pull requests to correct me or add new contents are definitely welcome.


  1. Some problems are listed without solutions for exercises in each topic, which are promised to be solvable by the provided template (because at least I have already passed them with the template) but may not be the best solutions for the problems.

  2. The difficulty levels marked for those problems may be varied from the levels given by LeetCode officially because it is just my measurement for difficulty levels.

  3. Sometimes, I may give some challenges (marked as Advanced) from sources other than LeetCode, which seem more challenging and can’t be solved by the template directly. But a step forward from the idea in the templates may help solve them. Thus, I just leave them as optional challenges.

  4. I never have a premium subscription on or due to my poor financial condition. I won’t list any premium problem as material on this site because I guarantee to verify all solutions I post. Of course, I’ll extremely appreciate it if you are willing to sponsor me with a premium subscription on either LeetCode site to encourage me to update some premium problems. cyber begging

More about me


Indices and tables