# Python Templates for LeetCode My personal summerized LeetCode Python templates. [![Python](https://custom-icon-badges.herokuapp.com/badge/Python-3.10-blue?style=flat-square&logo=python&logoColor=white)](https://docs.python.org/3.10/) [![Twitter Follow](https://img.shields.io/twitter/follow/yangzhou301)](https://twitter.com/yangzhou301) [![LeetCode user xy-li](https://img.shields.io/badge/dynamic/json?style=flat-square&labelColor=black&color=%23ffa116&label=Solved&query=solvedOverTotal&url=https%3A%2F%2Fbadge.xyli.tech/%2Fapi%2Fusers%2Fxy-li&logo=leetcode&logoColor=yellow)](https://leetcode.com/xy-li/) {octicon}`star` Star me on GitHub: [![](https://img.shields.io/github/stars/li-xin-yi/lctemplates?style=social)](https://github.com/li-xin-yi/lctemplates) {octicon}`megaphone` 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 {octicon}`comment` on the corresponding pages, and your comment will be kept as a comment for a GitHub issue {octicon}`issue-opened` permanently. Besides, pull requests {octicon}`git-pull-request` to correct me or add new contents are definitely welcome. ```{toctree} :maxdepth: 1 :caption: Home Prefix Sum Diff Array Lazy Update Binary Search Binary Lifting Substring Problem Segment Tree Union Find Computational Geometry Some Tips for Python in LeetCode Other Tricks Miscellaneous ``` ## Notes 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 {bdg-info}`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 leetcode.com or leetcode.cn 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 [{octicon}`gift` sponsor me](https://github.com/sponsors/li-xin-yi) with a _premium_ subscription on either LeetCode site to encourage me to update some _premium_ problems. {bdg-dark}`cyber begging` ## More about me - [Videos](https://space.bilibili.com/62988): My Bilibili channel, Chinese only,cracking every LeetCode with my friend and discuss in an interactive way. - [My solutions for LeetCode weekly contests](http://notebook.xyli.me/categories/LeetCode/) (_Chinese only, very very early stage, till 174 (02/01/2020)_) - [My paper reading notes](https://paper-weekly.readthedocs.io/en/latest/), mainly about ML/Security. - The LeetCode badges on the header are generated by [badges.xyli.codes](https://badges.xyli.codes/) (star me: [![](https://img.shields.io/github/stars/li-xin-yi/leetcode-badge?style=social)](https://github.com/li-xin-yi/leetcode-badge)), I modified code from [@cascandaliato's leetcode-badge](https://github.com/cascandaliato/leetcode-badge) to add contest rating and data for users in [leetcode.cn](https://leetcode.cn/). - Open to any dev/research intern opportunity ({octicon}`location` US or remote). If you have interest in working with me, please contact [{octicon}`mail` wolixinyi@gmail.com](mailto:wolixinyi@gmail.com) - [{octicon}`gift` Sponsor me!](https://github.com/sponsors/li-xin-yi) I'm in a poor financial condition due to the suspending research funding now. I can hardly survive this summer, help me! {bdg-dark}`cyber begging` ## Resources - [OI Wiki](https://oi-wiki.org/) (Chinese only), basic knowledge for competitive programming. - [Algorithms for Competitive Programming](https://cp-algorithms.com/), English translation of e-maxx.ru/algo, which includes descriptions of many algorithms and data structures especially popular in field of competitive programming. - [An awesome list for competitive programming!](https://codeforces.com/blog/entry/23054) - [clist.by](https://clist.by/), collecting coding contests recently and showing the changes of your history rating. - [Leetcode Rating Predictor](https://lccn.lbao.site/), predicting your rating changes right after the completion of Leetcode contests. (*new*: dynamic plots during the contest) - [Leetcode Problems Rating](https://zerotrac.github.io/leetcode_problem_rating/), credit to [@zerotrac](https://leetcode.cn/u/zerotrac2/), measuring the difficulty levels for problems. - [Test Case Generator](https://test-case-generator.herokuapp.com/), generating test cases with some given constraints. - [{octicon}`people` Cruel Coding Group](http://board.cruelcoding.com/) {bdg-primary}`youxiu is our habit` - [Chrome Codeium Extension](https://github.com/Exafunction/codeium-chrome), an in-line code auto completion extension that can be used in LeetCode editor, which is also what I contributed to. (now can't be used on LeetCode, but may help in other coding environments) - [Curated LeetCode Solutions](https://github.com/EndlessCheng/codeforces-go/blob/master/leetcode/SOLUTIONS.md), author [@0x3f](http://space.bilibili.com/206214) collected and organized by topic, various difficulty levels ## Indices and tables - {ref}`genindex` - {ref}`search`