课程大纲:
第一课:链表
- 链表的基础知识
- 例1-链表逆序 (LeetCode 206)
- 例2-链表中间段逆序(LeetCode 92)
- 例3-求两个链表的交点(LeetCode 160)
- 例4-两个排序链表的合并(LeetCode 21)
- 例5-链表求环(LeetCode 142)
- 例6-链表划分(LeetCode 86)
import hashlib | |
def md5(fname): | |
hash_md5 = hashlib.md5() | |
with open(fname, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
hash_md5.update(chunk) | |
return hash_md5.hexdigest() | |
from operator import xor | |
from functools import reduce | |
a = [2,3,3,2,1] | |
r = reduce(xor, a, 0) | |
# r = 1 |
课程大纲:
第一课:链表
git rebase i id |
ps -ef|grep python|grep -v grep|cut -c 7-12 | xargs kill -9 |
BAIDUNEWS_UTC_FORMAT_PATTERN1 = r'^(?P<publisher>\S+)\s+(((?P<year>\d{4})年(?P<month>\d{2})月(?P<day>\d{2})日\s+(?P<hour>\d{2}):(?P<minute>\d{2}))|(?P<beforetime>(?P<pubint>\d+)(?P<pubtype>分钟|小时)前))$' |
def max_count(string): | |
"""count max length of no-26 length | |
>>> max_count('') | |
0 | |
>>> max_count('1') | |
1 | |
>>> max_count('12') |
def delete_reoccurring_chars(string): | |
"""Return the string after deduplication. | |
>>> delete_reoccurring_chars('metasotaaaa') | |
'metasota' | |
>>> delete_reoccurring_chars('mmeettaassoottaa') | |
'metasota' | |
>>> delete_reoccurring_chars('metasota') | |
'metasota' |
import unittest | |
def dp(nums, m, n, i, j, visit): | |
ll, uu, rr, dd = [], [], [], [] | |
if i - 1 >= 0 and not visit[i - 1][j] and nums[i - 1][j] < nums[i][j]: | |
visit[i][j] = True | |
uu = dp(nums, m, n, i - 1, j, visit) | |
if j - 1 >= 0 and not visit[i][j - 1] and nums[i][j - 1] < nums[i][j]: | |
visit[i][j] = True |