01 2022 档案

摘要:class Solution: def maxArea(self, height: List[int]) -> int: # 问题的本质,就是(i-j)*min(List[i],List[j]) # 如果移动长板,那么面积就一定会减小 # 所以在移动的时候,一定是移动短板 # 经典双指针问题 Lef 阅读全文
posted @ 2022-01-06 10:42 MoKin_Li 阅读(24) 评论(0) 推荐(0) 编辑
摘要:# 逆向循环: >>> ListA = [0, 1, 2, 1, 4, 1, 6, 1, 8, 1] >>> for i in reversed(range(len(ListA))): ... print(i) ... 9 8 7 6 5 4 3 2 1 0 # 正向循环 >>> ListA = [ 阅读全文
posted @ 2022-01-05 11:26 MoKin_Li 阅读(683) 评论(0) 推荐(0) 编辑
摘要:class Solution: def removeElement(self, nums: List[int], val: int) -> int: while val in nums: nums.remove(val) return len(nums) remove()方法在使用过程中,往往需要结 阅读全文
posted @ 2022-01-05 11:07 MoKin_Li 阅读(30) 评论(0) 推荐(0) 编辑
摘要:4、使用count()方法 Python count() 方法用于统计字符串里某个字符或子字符串出现的次数。可选参数为在字符串搜索的开始与结束位置。 >>> str='aaabaaaabaaabaaaabaaaabaaaabaaaaba' >>> substr='aaaba' >>> str.cou 阅读全文
posted @ 2022-01-04 19:20 MoKin_Li 阅读(44) 评论(0) 推荐(0) 编辑
摘要:3、使用index()和rindex(): >>> str = "this is really a string example....wow!!!" >>> substr = "is" >>> print(str.index(substr)) 2 >>> print(str.rindex(subs 阅读全文
posted @ 2022-01-04 18:17 MoKin_Li 阅读(36) 评论(0) 推荐(0) 编辑
摘要:考察的重点,是Python判断字符串是否包含另一字符串 class Solution: def maxRepeating(self, sequence: str, word: str) -> int: for _i in range(1,100): if word * _i in sequence: 阅读全文
posted @ 2022-01-04 18:12 MoKin_Li 阅读(50) 评论(0) 推荐(0) 编辑