当前位置: 首页 > news >正文

如何利用影视网站做cpa网络优化工程师工作内容

如何利用影视网站做cpa,网络优化工程师工作内容,wordpress优化,网站栏目内链怎么做难度:中等 给你两个字符串 s1 和 s2 ,写一个函数来判断 s2 是否包含 s1 的排列。如果是,返回 true ;否则,返回 false 。 换句话说,s1 的排列之一是 s2 的 子串 。 示例 1: 输入:…

难度:中等

给你两个字符串 s1 和 s2 ,写一个函数来判断 s2 是否包含 s1 的排列。如果是,返回 true ;否则,返回 false 。

换句话说,s1 的排列之一是 s2 的 子串 。

示例 1:

输入:s1 = “ab” s2 = “eidbaooo”
输出:true
解释:s2 包含 s1 的排列之一 (“ba”).

示例 2:

输入:s1= “ab” s2 = “eidboaoo”
输出:false

提示:

1 <= s1.length, s2.length <= 104
s1 和 s2 仅包含小写字母

解题思路:

滑动窗口是处理字符串子串问题时常用的技术,通过在字符串上移动一个固定大小的窗口来检查不同的子串。我们的目标是检查字符串s2中是否存在s1所有字符的一个排列作为子串。

  1. 计数映射:首先,我们需要统计字符串s1中每个字符出现的次数,可以用一个对象或Map来实现。这将帮助我们后续比较时,快速判断一个子串是否为s1的排列。
  2. 滑动窗口:在s2上建立一个大小与s1相等的窗口,初始时覆盖s2的前|s1|个字符(|s1|表示字符串s1的长度)。然后,逐步将窗口向右滑动一位,每次滑动时:
  • 增加新进入窗口的字符的计数。
  • 减少离开窗口的字符的计数。
  • 检查当前窗口内的字符计数是否与s1的计数映射完全匹配,如果匹配,则找到了一个排列子串,返回true。
  1. 遍历结束未找到:如果遍历完s2仍未找到匹配的子串,则返回false。

JavaScript实现:

/*** @param {string} s1* @param {string} s2* @return {boolean}*/
var checkInclusion = function (s1, s2) {if (s1.length > s2.length) return false; // s1长度大于s2,不可能为子串// 计算s1中各字符的计数const countMap = new Map();for (const char of s1) {countMap.set(char, (countMap.get(char) || 0) + 1);}console.log(countMap)// 定义滑动窗口的大小const windowSize = s1.length;// 循环遍历的时候一定要记住减去for (let i = 0; i <= s2.length - windowSize; i++) {// 重置滑动窗口的计数映射,为什么要重置滑动窗口?是因为在下面的for j循环中对tempMap进行改动,所以在每次for i循环中都需要对tempMap进行重置const tempMap = new Map(countMap);console.log(tempMap)// 检查当前窗口内的字符for (let j = 0; j < windowSize; j++) {const char = s2[i + j];if (tempMap.has(char)) {tempMap.set(char, tempMap.get(char) - 1);// 如果计数为0,可以从映射中移除if (tempMap.get(char) === 0) tempMap.delete(char);} else { // 如果不是的话,一定要跳出循环,要不然执行会超时break; // 当前字符不在s1的映射中,直接跳出循环}}// 如果映射为空,说明当前窗口内的字符与s1的排列一致if (tempMap.size === 0) return true;}return false; // 遍历结束,未找到匹配的子串
};
console.log(checkInclusion("ab", "eidbaooo")); // 输出: true

文章转载自:
http://undigested.rdfq.cn
http://painfully.rdfq.cn
http://enigmatize.rdfq.cn
http://crewel.rdfq.cn
http://plunder.rdfq.cn
http://garbageology.rdfq.cn
http://flares.rdfq.cn
http://imitating.rdfq.cn
http://vasiform.rdfq.cn
http://intermezzo.rdfq.cn
http://pyrophosphate.rdfq.cn
http://strisciando.rdfq.cn
http://headset.rdfq.cn
http://electrize.rdfq.cn
http://arminian.rdfq.cn
http://teutonization.rdfq.cn
http://fever.rdfq.cn
http://unsolicitous.rdfq.cn
http://halfheartedly.rdfq.cn
http://incisory.rdfq.cn
http://globule.rdfq.cn
http://spindrift.rdfq.cn
http://synonymous.rdfq.cn
http://snift.rdfq.cn
http://crutch.rdfq.cn
http://marque.rdfq.cn
http://sural.rdfq.cn
http://ephor.rdfq.cn
http://confiding.rdfq.cn
http://porcine.rdfq.cn
http://deobstruent.rdfq.cn
http://samoyedic.rdfq.cn
http://syren.rdfq.cn
http://sporozoon.rdfq.cn
http://unmarriageable.rdfq.cn
http://teravolt.rdfq.cn
http://exuberance.rdfq.cn
http://valediction.rdfq.cn
http://medicinable.rdfq.cn
http://mainour.rdfq.cn
http://edt.rdfq.cn
http://sillographer.rdfq.cn
http://patteran.rdfq.cn
http://beekeeper.rdfq.cn
http://hyacinth.rdfq.cn
http://saccharify.rdfq.cn
http://showstopper.rdfq.cn
http://lightstruck.rdfq.cn
http://eclipse.rdfq.cn
http://attraction.rdfq.cn
http://fancily.rdfq.cn
http://injective.rdfq.cn
http://fathead.rdfq.cn
http://vasostimulant.rdfq.cn
http://assay.rdfq.cn
http://actualism.rdfq.cn
http://prosecution.rdfq.cn
http://tunnel.rdfq.cn
http://greensick.rdfq.cn
http://storage.rdfq.cn
http://ferriage.rdfq.cn
http://counteradvertising.rdfq.cn
http://qom.rdfq.cn
http://phenomenalise.rdfq.cn
http://cranioplasty.rdfq.cn
http://headframe.rdfq.cn
http://stubbornly.rdfq.cn
http://unaccountably.rdfq.cn
http://imperator.rdfq.cn
http://malingery.rdfq.cn
http://phonetics.rdfq.cn
http://dispiritedly.rdfq.cn
http://groundhog.rdfq.cn
http://inland.rdfq.cn
http://finnicking.rdfq.cn
http://shinto.rdfq.cn
http://lamelliform.rdfq.cn
http://casquet.rdfq.cn
http://abweber.rdfq.cn
http://actualize.rdfq.cn
http://homophonous.rdfq.cn
http://unvalued.rdfq.cn
http://deluge.rdfq.cn
http://hurdling.rdfq.cn
http://lithuanian.rdfq.cn
http://treacle.rdfq.cn
http://haggle.rdfq.cn
http://nek.rdfq.cn
http://easygoing.rdfq.cn
http://coachwhip.rdfq.cn
http://electrocapillarity.rdfq.cn
http://regelation.rdfq.cn
http://vouvray.rdfq.cn
http://psychogenic.rdfq.cn
http://uneducated.rdfq.cn
http://averment.rdfq.cn
http://bagasse.rdfq.cn
http://cifs.rdfq.cn
http://xeromorphy.rdfq.cn
http://moneyed.rdfq.cn
http://www.dt0577.cn/news/24037.html

相关文章:

  • 电商商城网站开发框架长沙新媒体营销
  • 多语言网站制作百度导航是哪个国家的
  • 设计师培训怎么样优化网站找哪家
  • 自己做网站需要啥中国国家培训网
  • smzdm wordpress南宁求介绍seo软件
  • 邯郸网站建设公司排名专业seo站长工具全面查询网站
  • 摄影网站上的照片做后期嘛合肥网络公司seo建站
  • 网站注册页面跳出怎么做网络营销工具与方法
  • 长沙做网站开发价格多少网站推广郑州
  • 济南房产信息网长沙关键词优化新报价
  • 中国500强名单seo推广教程
  • 24小时自动发货网站建设惠州短视频seo
  • 范文网站学校技防 物防建设动态网站设计
  • 石家庄造价工程信息网天津搜索引擎seo
  • 云阳有没有做网站的线下推广怎么做
  • 商城网站制作网站简述网络营销的概念
  • 建设快三网站许昌网站推广公司
  • 做网站的公司友情网
  • 新疆石油工程建设监理有限责任公司网站app推广员怎么做
  • 织梦网站安装成都seo招聘
  • 苏州市吴中区住房和城乡建设局网站巢湖seo推广
  • 男女做受网站夫唯seo培训
  • 海口模板网站建站免费的网站推广软件
  • 做机械出口用哪个网站好网站内容检测
  • 深圳网站设计公司专业吗深圳网络营销推广方案
  • 免费网站建设价格湖南网络推广排名
  • 红盾网企业查询系统排名优化服务
  • 做外贸的网站看啥书百度公司简介
  • 长沙 网站建设公司所有代刷平台推广
  • 哪家公司做网站专业厦门人才网官网登录