Skip to content

Commit fd713d9

Browse files
committed
Deployed a7e0de4 with MkDocs version: 1.0.4
1 parent e74aeac commit fd713d9

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

19_python内置常用算法和数据结构/builtins/index.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,16 @@
188188
<li class="toctree-l2"><a href="#python_1">python 如何实现最大堆</a></li>
189189

190190

191+
<li class="toctree-l2"><a href="#lru_cachecache">lru_cache/cache 优化记忆化搜索</a></li>
192+
193+
191194
<li class="toctree-l2"><a href="#leetcode">leetcode 二叉树调试函数</a></li>
192195

193196

194197
<li class="toctree-l2"><a href="#python_2">python 交换列表元素的坑</a></li>
195198

196199

197-
<li class="toctree-l2"><a href="#_4">兼容提交格式</a></li>
200+
<li class="toctree-l2"><a href="#_4">兼容代码提交格式</a></li>
198201

199202

200203
</ul>
@@ -499,19 +502,16 @@ <h1 id="python_1">python 如何实现最大堆</h1>
499502

500503
def maxheapval(h):
501504
return -h[0]
502-
``````
503-
504-
# lru_cache/cache 优化记忆化搜索
505-
506-
python3 functools 模块的 cache 功能和 lru_cache(maxsize=None) 一样,不过更加轻量更快。在记忆化递归搜索的时候很方便。
507-
举一个力扣上的例子,如果不加 cache 递归函数因为会大量重复计算直接超时,但是加一个装饰器就可以通过。
508-
509-
```py
510-
&quot;&quot;&quot;
505+
</code></pre>
506+
<h1 id="lru_cachecache">lru_cache/cache 优化记忆化搜索</h1>
507+
<p>python3 functools 模块的 cache 功能和 lru_cache(maxsize=None) 一样,不过更加轻量更快。在记忆化递归搜索的时候很方便。
508+
举一个力扣上的例子,如果不加 cache 递归函数因为会大量重复计算直接超时,但是加一个装饰器就可以通过。</p>
509+
<pre><code class="language-py">&quot;&quot;&quot;
511510
[337] 打家劫舍 III
512511
https://leetcode-cn.com/problems/house-robber-iii/description/
513512
&quot;&quot;&quot;
514-
from functools import cache, lru_cache # cache 等价于 functools.lru_cache(maxsize=None)
513+
# cache 等价于 functools.lru_cache(maxsize=None), 不过python3版本低可能没有 cache 只有 lru_cache
514+
from functools import cache, lru_cache
515515

516516

517517
class Solution(object):
@@ -521,7 +521,7 @@ <h1 id="python_1">python 如何实现最大堆</h1>
521521
:type root: TreeNode
522522
:rtype: int
523523
&quot;&quot;&quot;
524-
# @lru_cache(maxsize=None)
524+
# @lru_cache(maxsize=None) # 注意如果 python3 版本不是很新的话,只能用 lru_cache(maxsize=None)
525525
@cache # NOTE: 不加 cache 会直接超时,就只能用动态规划了
526526
def dfs(root):
527527
if root is None:
@@ -683,10 +683,10 @@ <h1 id="python_2">python 交换列表元素的坑</h1>
683683

684684
return n+1
685685
</code></pre>
686-
<h1 id="_4">兼容提交格式</h1>
686+
<h1 id="_4">兼容代码提交格式</h1>
687687
<p>注意牛客网有两种模式,一种是和 leetcode 一样的提交(无需处理输入),只需要提交核心代码。
688688
一种是 ACM 模式,还需要自己处理输入和输出。
689-
建议使用这种兼容写法,同样的题目可以同时提交到 牛客和leetcode
689+
建议使用这种兼容写法,同样的题目可以同时提交到 牛客、leetcode 和 acwing(python3)
690690
这道题目为例子 [679] 奖品分配 https://www.acwing.com/problem/content/681/</p>
691691
<pre><code class="language-py"># 这段代码可以直接以OJ输入模式提交,如果题目一样,直接复制 Solution 类就可以同时提交到leetcode
692692
class Solution:

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,5 +599,5 @@ <h2 id="_22">本电子书制作和写作方式</h2>
599599

600600
<!--
601601
MkDocs version : 1.0.4
602-
Build Date UTC : 2022-02-20 03:59:08
602+
Build Date UTC : 2022-02-20 04:04:25
603603
-->

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)