![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pyhton
文章平均质量分 52
cszhang570221322
本人暂时是一名学习软件工程的学生,发布的blog暂时是自己的学习笔记而已,望大神不喜勿怒
展开
-
Merge Sort. $O(1),O(N\log N) $
归并排序Tips:1. a = b + c*2**k2. b = a % c = a & (k-1)3. c = a // 2**k = a >> kFor example:1. 643 = 3 + 20*2**52. 3 = 643 % 32 = 643 & 313. 20 = 643 // 32 = 643 >> 5import mathfrom typing import Listdef getPower2(n: int原创 2021-03-20 22:49:17 · 168 阅读 · 3 评论 -
leetcode. (1141)Longest Common Subsequence. (1092)Shortest Common Supersequence.
求多个子串{s1,...,sn}\{s_1,...,s_n\}{s1,...,sn}的序列组合问题.核心点要关注多维DP数组所存储的信息, DP数组里的信息有:字符串sis_isi和sjs_jsj相互比较的信息是一个隐马尔科夫的过程dp[i][j]的状态只与他的pre状态有关.其pre状态是根据状态转移方程来定的.回溯时要从后往前回溯, 根据状态的变化规则和想要的最终字符串回溯即可.对于高纬度多个字符串相比较, 其也是一样的, 只不过状态转移方程的参数要变多.下面是LCS原创 2021-03-16 14:38:32 · 169 阅读 · 1 评论 -
Python, Permutation and Combination
Python, Permutation and Combination排列和组合排列 P(n,r)=Anr=n!(n−r)!P(n,r)=A_n^r = \frac{n!}{(n-r)!}P(n,r)=Anr=(n−r)!n!组合 C(n,r)=Cnr=(rn)=n!r!(n−r)!C(n,r)=C_n^r=(_r^n)=\frac{n!}{r!(n-r)!}C(n,r)=Cnr=(rn)=r!(n−r)!n!重复:放回不放回参考 Math is Fun例子[1,2,3,4]排列无原创 2021-03-03 15:52:49 · 183 阅读 · 4 评论 -
Coroutine singleThread MutiThread Mutiprocess (python3.8 环境)
asyncio vs syncio (python3.8 环境)asyncio1aiohttp_test.pyimport asyncioimport threadingimport osfrom aiohttp import webasync def index(request): # 耗时的io操作 await asyncio.sleep(3) text = '<h1>pid %d , threading %s </h1>' % (原创 2021-01-06 00:38:50 · 165 阅读 · 1 评论 -
pyhon学习笔记
pyhon学习笔记原创 2016-10-11 19:01:59 · 519 阅读 · 4 评论 -
Python tile函数详细解释
Title函数函数形式: tile(A,rep)功能:重复A的各个维度参数类型:- A: Array类的都可以- rep:A沿着各个维度重复的次数(由外至内)Note:返回的结果的维度是max(A.ndim,req.length),出现三种情况1、A.ndim=req.length如: tile([[1],[2]],(1,2)) , A为[[1],[...原创 2018-12-19 20:43:32 · 5826 阅读 · 1 评论