2019年10月29日

四指针法

摘要: str1 = '666python6666sdafagagsdgas' str2 = '3333python6' # 要求两个字符串中的相同部分,我们先用常规的思路实现,然后再用经典的四指针法 # 常规思路是我们将字符串中的每一块都切割出来然后与str1进行比较 def check(str1,str2): maxLenth = 0 result = '' # 将str2中的所有可能重合的字符进行切 阅读全文

posted @ 2019-10-29 14:55 素心~ 阅读(277) 评论(0) 推荐(0) 编辑

因数法

摘要: # 我们将一个字符串重复输出 def repeat(str,count): result = "" for i in range(count): result = result + str return result print(repeat('@',5)) # 使用因数法来优化函数,因数法的逻辑来源于任何数字都可以拆分为二进制 def factorRepeat(str,count): resul 阅读全文

posted @ 2019-10-29 13:16 素心~ 阅读(326) 评论(0) 推荐(0) 编辑

导航