
LeetCode
LeetCode
YangJSJ
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
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 · 169 阅读 · 0 评论 -
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 · 402 阅读 · 0 评论 -
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 · 348 阅读 · 0 评论 -
LeetCode-DFS
加起来和为目标值的组合: 给定一个由不同整数构成的数组 nums 和一个整数 target ,请你从 nums 找出总和是 target 的组合的个数。解集中可以重复使用 nums 中的元素。且解集中数字顺序不同视为不同的组合。 解法一、DFS out=0 class Solution: def combination(self , nums , target ): nums.sort() numlen=len(nums) def dfs(t)原创 2022-02-28 22:56:29 · 385 阅读 · 0 评论 -
LeetCode-动态规划
一、字符串 1.两个字符串 s 和 t,判断 t 是否是 s 的子序列?注意,子序列不要求在原字符串中是连续的 2.两个字符串 s 和 t,判断 t 是否是 s 的子串?注意,子串要求在原字符串中是连续的。 3. ...原创 2022-01-25 00:55:51 · 180 阅读 · 0 评论 -
LeetCode Python基础常识
1.常用的python包 #collections import collections st=collections.deque() d=deque([1,2,3,4,5,0]) d.extendleft([6,7,8]) d.append(1) d.pop() d.leftpop() #set s=set() s.add(3) s.pop(3) 3 in s #list list=[] 取list的截断:a[start:end](左边包括,右边不包括),index从0开始 arr = [[原创 2022-01-24 23:54:44 · 637 阅读 · 0 评论 -
[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 · 651 阅读 · 0 评论