百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

Algorithm_Templates

> 编程语言
开源

在 Python3 中的算法模板和 Leetcode 示例中,您还可以学习许多 Python 的技巧。

391 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在 Python3 中的算法模板和 Leetcode 示例中,您还可以学习许多 Python 的技巧。

Algorithm Templates

Description

Templates and examples in Python3, including common data structure & algorithms.

I have collected and summarized general code templates for particular algorithms, and add most typical examples to help make better use of it. All the examples come from LeetCode, and I have attached the problem id and brief description.

"Stop Trying to Reinvent the Wheel"

So I try my best to find the commonality in problems, solutions and codes. When I study, I have summarized templates for future use.

First I intended to use it for myself, and now I realize maybe it is good enough to share with people who also need it.

Supplementary explanation

  1. It is written in Python3, but easy to extend to other languages, such as Java, C++. Just replace the python syntactic sugar and advanced tricks, maybe just less concise.

  2. With my limited time and ability, here only covers common data structure & algorithms. Almost suitable for interview, but insufficient for competition.

  3. I have tried my best to collect and summarize the most general and best-practice templates in particular area, but this version may not be the best solution. Or, it's really the best performance and most concise solution, but it's not the suitable for you. Within acceptable performance, it is the best practice for you when you use it most conveniently.

  4. Code templates is written by python with some pseudo code, so I use self and add stub functions to pass compiler's check. You should replace them with your particular logic according to the comments.

Why Python?

"life is short, you need python"

With the help of Python's advanced features, it can let us ignore redundant grammar, and totally focus on algorithm and logic.

Besides, it is popular, and I'm the big fan of this language myself.

Who is this for?

  1. If you will have interviews soon, and plan to review data structure & algorithm. You can review by these summary, and improve practical skills by typical examples.
  2. If you want to study algorithm by practice, here you can understand the key point in templates, and practice the examples from easy to hard, to understand it deeper.
  3. If you are a LeetCoder, you want to focus on your weak topics, and have no idea to which problems to solve, here is well classified and provides the most typical examples. Or, you are too tired to find a fastest and elegant answer in discussion, here can save your time.
  4. If you are a python beginner, and want to enhance your advanced pythonic skills, you can focus on python tricks. Hope you will find useful and elegant techniques here.

Thanks to

  • Thanks to all good problems from LeetCode. In addition, LeetCode has a great OJ platform, and really suitable to do functional and performance test.
  • Many templates and tricks are enlightened by discussions in LeetCode, thanks to all the code masters.
  • Special thanks to Stefan Pochmann, really learned a lot from him.

MIT License

Feel free to use, copy, modify, merge or publish. just add a reference, please.

If it helps you or you like it, you can star or share it. thanks : )

I'm glad if you want to contribute to make it better.

Reference

  • https://leetcode.com/problemset/all/
  • https://leetcode.com/discuss/
  • https://time.geekbang.org/course/intro/130
  • https://time.geekbang.org/column/intro/126
  • https://www.wikipedia.org/
  • https://stackoverflow.com/
  • https://github.com/brennerm/PyTricks

Generalization Discussions scraping from LeetCode

I scrape the most popular discussions and filter the ones which summarized a general approach to particular domain, such as backtracking, dynamic programming, sliding window, bit manipulation.

Well worth reading:

  • sliding window

  • bit manipulation

  • dynamic programming

  • solving array-related problems

  • binary tree traversal

  • backtracking

  • bitwise operation for single numbers

Contact

[email protected]

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonalgorithmdata-structureleetcodeleetcode-python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言