Skip to content

Commit 2f69503

Browse files
committed
Deployed 5d63cf3 with MkDocs version: 1.0.4
1 parent 598449b commit 2f69503

File tree

5 files changed

+45
-30
lines changed

5 files changed

+45
-30
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@
173173
<li class="toctree-l2"><a href="#_1">一些坑</a></li>
174174

175175

176+
<li class="toctree-l2"><a href="#python_1">python 递归暴栈(栈溢出)</a></li>
177+
178+
176179
<li class="toctree-l2"><a href="#python-int">python int 值范围</a></li>
177180

178181

@@ -185,7 +188,7 @@
185188
<li class="toctree-l2"><a href="#_3">内置库实现优先级队列的三种方式</a></li>
186189

187190

188-
<li class="toctree-l2"><a href="#python_1">python 如何实现最大堆</a></li>
191+
<li class="toctree-l2"><a href="#python_2">python 如何实现最大堆</a></li>
189192

190193

191194
<li class="toctree-l2"><a href="#lru_cachecache">lru_cache/cache 优化记忆化搜索</a></li>
@@ -194,7 +197,7 @@
194197
<li class="toctree-l2"><a href="#leetcode">leetcode 二叉树调试函数</a></li>
195198

196199

197-
<li class="toctree-l2"><a href="#python_2">python 交换列表元素的坑</a></li>
200+
<li class="toctree-l2"><a href="#python_3">python 交换列表元素的坑</a></li>
198201

199202

200203
<li class="toctree-l2"><a href="#acm">兼容代码ACM/核心提交格式</a></li>
@@ -325,6 +328,18 @@ <h1 id="_1">一些坑</h1>
325328
<li>自定义排序函数。python2 可以用 <code>nums.sort(cmp=lambda a, b: a - b)</code>,但是python3移除了cmp参数。
326329
python3如果想要用自定义排序函数可以使用 functools.cmp_to_key 函数改成 <code>nums.sort(key=cmp_to_key(lambda a, b: a - b))</code></li>
327330
</ul>
331+
<h1 id="python_1">python 递归暴栈(栈溢出)</h1>
332+
<p>python 递归函数默认递归深度比较小,你可以通过 <code>sys.getrecursionlimit()</code> 函数打印出来。
333+
我在 mac 机器上测试的时候,以下结果 python2 输出 1000。这就导致一些递归函数测试用例稍微多一些就会报错。
334+
(一个用例超过上千个数据就会报错了)</p>
335+
<pre><code class="language-py">import sys
336+
print(sys.getrecursionlimit()) # 我的 mac 机器上输出 1000
337+
</code></pre>
338+
<p>可以把以下代码设置最大栈深度,放到文件开头,在牛客上提交代码的时候可以避免一些递归代码报错。
339+
(leetcode 似乎给设置了,类似的题目发现力扣上提交不会栈溢出但是在牛客就会)</p>
340+
<pre><code class="language-py">import sys
341+
sys.setrecursionlimit(100000) # 设置函数栈深度足够大,避免栈溢出错误
342+
</code></pre>
328343
<h1 id="python-int">python int 值范围</h1>
329344
<pre><code># 乘方 (比较推荐,py2/3 都兼容不容易出错)
330345
MAXINT = 2**63-1
@@ -497,7 +512,7 @@ <h1 id="_3">内置库实现优先级队列的三种方式</h1>
497512
while pq:
498513
print(heapq.heappop(pq))
499514
</code></pre>
500-
<h1 id="python_1">python 如何实现最大堆</h1>
515+
<h1 id="python_2">python 如何实现最大堆</h1>
501516
<p>python自带了heapq 模块实现了最小堆(min-heaq),但是如果想要实现最大堆(max-heap),有几种实现方式:</p>
502517
<ol>
503518
<li>对放入的数字取反。比如 10 放入 -10 ,然后取出来的时候再取反。个人倾向于这种,可以自己封装一个类防止来回取反搞晕</li>
@@ -690,7 +705,7 @@ <h1 id="leetcode">leetcode 二叉树调试函数</h1>
690705
cur.right = right
691706
return root
692707
</code></pre>
693-
<h1 id="python_2">python 交换列表元素的坑</h1>
708+
<h1 id="python_3">python 交换列表元素的坑</h1>
694709
<pre><code># 41. 缺失的第一个正数 https://leetcode-cn.com/problems/first-missing-positive/
695710
class Solution(object):
696711
def firstMissingPositive(self, nums):

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-04-14 05:28:25
602+
Build Date UTC : 2022-04-26 01:31:17
603603
-->

search/search_index.json

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

sitemap.xml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,122 +2,122 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>None</loc>
5-
<lastmod>2022-04-14</lastmod>
5+
<lastmod>2022-04-26</lastmod>
66
<changefreq>daily</changefreq>
77
</url>
88
<url>
99
<loc>None</loc>
10-
<lastmod>2022-04-14</lastmod>
10+
<lastmod>2022-04-26</lastmod>
1111
<changefreq>daily</changefreq>
1212
</url>
1313
<url>
1414
<loc>None</loc>
15-
<lastmod>2022-04-14</lastmod>
15+
<lastmod>2022-04-26</lastmod>
1616
<changefreq>daily</changefreq>
1717
</url>
1818
<url>
1919
<loc>None</loc>
20-
<lastmod>2022-04-14</lastmod>
20+
<lastmod>2022-04-26</lastmod>
2121
<changefreq>daily</changefreq>
2222
</url>
2323
<url>
2424
<loc>None</loc>
25-
<lastmod>2022-04-14</lastmod>
25+
<lastmod>2022-04-26</lastmod>
2626
<changefreq>daily</changefreq>
2727
</url>
2828
<url>
2929
<loc>None</loc>
30-
<lastmod>2022-04-14</lastmod>
30+
<lastmod>2022-04-26</lastmod>
3131
<changefreq>daily</changefreq>
3232
</url>
3333
<url>
3434
<loc>None</loc>
35-
<lastmod>2022-04-14</lastmod>
35+
<lastmod>2022-04-26</lastmod>
3636
<changefreq>daily</changefreq>
3737
</url>
3838
<url>
3939
<loc>None</loc>
40-
<lastmod>2022-04-14</lastmod>
40+
<lastmod>2022-04-26</lastmod>
4141
<changefreq>daily</changefreq>
4242
</url>
4343
<url>
4444
<loc>None</loc>
45-
<lastmod>2022-04-14</lastmod>
45+
<lastmod>2022-04-26</lastmod>
4646
<changefreq>daily</changefreq>
4747
</url>
4848
<url>
4949
<loc>None</loc>
50-
<lastmod>2022-04-14</lastmod>
50+
<lastmod>2022-04-26</lastmod>
5151
<changefreq>daily</changefreq>
5252
</url>
5353
<url>
5454
<loc>None</loc>
55-
<lastmod>2022-04-14</lastmod>
55+
<lastmod>2022-04-26</lastmod>
5656
<changefreq>daily</changefreq>
5757
</url>
5858
<url>
5959
<loc>None</loc>
60-
<lastmod>2022-04-14</lastmod>
60+
<lastmod>2022-04-26</lastmod>
6161
<changefreq>daily</changefreq>
6262
</url>
6363
<url>
6464
<loc>None</loc>
65-
<lastmod>2022-04-14</lastmod>
65+
<lastmod>2022-04-26</lastmod>
6666
<changefreq>daily</changefreq>
6767
</url>
6868
<url>
6969
<loc>None</loc>
70-
<lastmod>2022-04-14</lastmod>
70+
<lastmod>2022-04-26</lastmod>
7171
<changefreq>daily</changefreq>
7272
</url>
7373
<url>
7474
<loc>None</loc>
75-
<lastmod>2022-04-14</lastmod>
75+
<lastmod>2022-04-26</lastmod>
7676
<changefreq>daily</changefreq>
7777
</url>
7878
<url>
7979
<loc>None</loc>
80-
<lastmod>2022-04-14</lastmod>
80+
<lastmod>2022-04-26</lastmod>
8181
<changefreq>daily</changefreq>
8282
</url>
8383
<url>
8484
<loc>None</loc>
85-
<lastmod>2022-04-14</lastmod>
85+
<lastmod>2022-04-26</lastmod>
8686
<changefreq>daily</changefreq>
8787
</url>
8888
<url>
8989
<loc>None</loc>
90-
<lastmod>2022-04-14</lastmod>
90+
<lastmod>2022-04-26</lastmod>
9191
<changefreq>daily</changefreq>
9292
</url>
9393
<url>
9494
<loc>None</loc>
95-
<lastmod>2022-04-14</lastmod>
95+
<lastmod>2022-04-26</lastmod>
9696
<changefreq>daily</changefreq>
9797
</url>
9898
<url>
9999
<loc>None</loc>
100-
<lastmod>2022-04-14</lastmod>
100+
<lastmod>2022-04-26</lastmod>
101101
<changefreq>daily</changefreq>
102102
</url>
103103
<url>
104104
<loc>None</loc>
105-
<lastmod>2022-04-14</lastmod>
105+
<lastmod>2022-04-26</lastmod>
106106
<changefreq>daily</changefreq>
107107
</url>
108108
<url>
109109
<loc>None</loc>
110-
<lastmod>2022-04-14</lastmod>
110+
<lastmod>2022-04-26</lastmod>
111111
<changefreq>daily</changefreq>
112112
</url>
113113
<url>
114114
<loc>None</loc>
115-
<lastmod>2022-04-14</lastmod>
115+
<lastmod>2022-04-26</lastmod>
116116
<changefreq>daily</changefreq>
117117
</url>
118118
<url>
119119
<loc>None</loc>
120-
<lastmod>2022-04-14</lastmod>
120+
<lastmod>2022-04-26</lastmod>
121121
<changefreq>daily</changefreq>
122122
</url>
123123
</urlset>

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)