- 博客(9)
- 收藏
- 关注
原创 LeetCode-其它
1. BM100设计LRU缓存结构设计LRU(最近最少使用)缓存结构,该结构在构造时确定大小,假设大小为 k ,操作次数是 n ,并有如下两个功能1. set(key, value):将记录(key, value)插入该结构2. get(key):返回key对应的value值提示:1.某个key的set或get操作一旦发生,认为这个key的记录成了最常使用的,然后都会刷新缓存。2.当缓存的大小超过k时,移除最不经常使用的记录。3.输入一个二维数组与k,二维数组每一维有2个或.
2022-03-15 01:14:05
168
原创 LeetCode-双指针
最小覆盖子串:给出两个字符串 s和 t,要求在 s中找出最短的包含 t中所有字符的连续子串。class Solution: def minWindow(self , S , T ): lens=len(S) needcnt={} for i in T: needcnt[i]=1 if i not in needcnt else needcnt[i]+1 totalneed=len(needcnt...
2022-03-15 00:42:10
395
原创 LeetCode-动态规划
一、正则表达式问题:请实现一个函数用来匹配包括'.'和'*'的正则表达式。1.模式中的字符'.'表示任意一个字符2.模式中的字符'*'表示它前面的字符可以出现任意次(包含0次)。在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配def match(self , str , pattern ): lens=len(str) lenp=len(patte
2022-03-14 23:57:07
344
原创 LeetCode-DFS
加起来和为目标值的组合:给定一个由不同整数构成的数组 nums 和一个整数 target ,请你从 nums 找出总和是 target 的组合的个数。解集中可以重复使用 nums 中的元素。且解集中数字顺序不同视为不同的组合。解法一、DFSout=0class Solution: def combination(self , nums , target ): nums.sort() numlen=len(nums) def dfs(t)
2022-02-28 22:56:29
379
原创 LeetCode-动态规划
一、字符串1.两个字符串 s 和 t,判断 t 是否是 s 的子序列?注意,子序列不要求在原字符串中是连续的2.两个字符串 s 和 t,判断 t 是否是 s 的子串?注意,子串要求在原字符串中是连续的。3....
2022-01-25 00:55:51
177
原创 LeetCode Python基础常识
1.常用的python包#collectionsimport collectionsst=collections.deque()d=deque([1,2,3,4,5,0])d.extendleft([6,7,8])d.append(1)d.pop()d.leftpop()#sets=set()s.add(3) s.pop(3)3 in s#listlist=[]取list的截断:a[start:end](左边包括,右边不包括),index从0开始arr = [[
2022-01-24 23:54:44
624
原创 [leetcode]t002-Median of Two Sorted Arrays
题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路:题目直接要求O()
2015-01-08 16:13:32
649
原创 统计之常用的分布
列举一下常用的概率分布。1. 离散均匀分布场景:掷骰子2. 二项分布(离散)场景:掷硬币首先描述一下什么是伯努利过程。伯努利过程: a.由n次实验构成 b.每次的实验结果非0(失败)即1(成功) c.每次实验的成功概率是
2014-10-22 11:42:20
4993
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人