解决题目的思路
- 1、暴力破解:使用笨方法,不考虑时间复杂度和空间复杂度,使用for循环外加创建新的数据结构
- 2、迭代方法:使用指针,一个指针搞定不了就是用两个,两个不行就三个…,多使用中间变量存储数据,多创建新的数据结构
- 3、递归方法(动态规划)
时间复杂度
优劣排序:O(1) > O(logn) > O(n) > O(nlogn) > O(n^2) > O(2^n) > O(n!)
重要工具…
-
python代码数据结构可视化:
- https://www.cs.usfca.edu/~galles/visualization
- http://pythontutor.com/live.html#mode=edit
-
leetcode(力扣)刷题网站:https://leetcode-cn.com/
-
视频教学:https://edu.csdn.net/course/play/29389/416882
-
算法题多使用内置函数和考虑时间复杂度
-
内置函数:https://docs.python.org/3/library/functions.html
-
-
pytest:测试工具
-
when-changed:自动监控文件并运行单元测试工具(看门狗)
- https://github.com/joh/when-changed
-
命令行执行: when-changed -r -v -1 'filepath' pytest -s 'filepath' -r(Watch recursively):监听 -v(Verbose output):输入详细的信息 -1:等待代码更新后才继续执行“filepath”文件 -s:是pytest的命令,输入print打印的信息