leetcode76】的更多相关文章

leetcode76. Minimum Window Substring 题意: 给定字符串S和字符串T,找到S中的最小窗口,其中将包含复杂度O(n)中T中的所有字符. 例如, S ="ADOBECODEBANC" T ="ABC" 最小窗口为"BANC". 注意: 如果S中没有覆盖T中所有字符的窗口,返回空字符串"". 如果有多个这样的窗口,您可以确保在S中始终只有一个唯一的最小窗口. 思路: 一个right指针遍历s,每次…
题目描述: 给定两个数组求他们的公共部分,输出形式是数组,相同的元素累计计数 例如: nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. 原文描述: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i…
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOBECODEBANC", T = "ABC" Output: "BANC" Note: If there is no such window in S…
 最小覆盖子串(hard) (不会) 给定一个字符串 S 和一个字符串 T,请在 S 中找出包含 T 所有字母的最小子串. 示例: 输入: S = "ADOBECODEBANC", T = "ABC" 输出: "BANC" 说明: 如果 S 中不存这样的子串,则返回空字符串 "". 如果 S 中存在这样的子串,我们保证它是唯一的答案. 关键:滑动窗口 参考 https://www.nowcoder.com/questionTe…
class Solution: def minWindow(self, s: str, t: str) -> str: n = len(s) if n==0: return "" if len(t)==0: return s #if s == t: # return s dic = {} dic2= {} for i in range(len(t)): dic.update({t[i]:0}) if t[i] in dic2.keys(): dic2.update({t[i]:d…
//1.single number和变体 //2.lru lfu 3.给一个正整数集合,求一个和最大且能被3整除的子集.Follow up: 如果集合里有正有负 4.leetcode200-number of islands;followup:leetcode694-Number of Distinct Islands,leetcode253 5.leetcode69 sqrt double (binary search) //6.很简单的二叉树题,判断树的所有节点value是不是都相同:fol…
子集和问题:给定一组数和一个值,从这组数中选出若干个数使其和为给定的值.这是个NPC问题. 1.https://leetcode.com/problems/counting-bits/#/solutions 给定一非负Integer num,求[0,num]每个数的二进制形式中1的个数  f[num+1]. 解法:可用最朴素的方法逐个求,但其实有规律: f[i] = f[i / ] + i % 或  f[i] = f[i&(i-)] + ; 2.Single Number:一组Integer类型…