哪些公司用.cc做网站WordPress手动切换主题
哪些公司用.cc做网站,WordPress手动切换主题,徐州网红有哪些人,网站扫二维码怎么做的#x1f468;⚕️ 主页#xff1a; gis分享者 #x1f468;⚕️ 感谢各位大佬 点赞#x1f44d; 收藏⭐ 留言#x1f4dd; 加关注✅! #x1f468;⚕️ 收录于专栏#xff1a;华为OD面试 文章目录一、#x1f340;前言1.1 ☘️题目详情1.2 ☘️参考解题答案一…⚕️主页 gis分享者⚕️感谢各位大佬 点赞 收藏⭐ 留言 加关注✅!⚕️收录于专栏华为OD面试文章目录一、前言1.1 ☘️题目详情1.2 ☘️参考解题答案一、前言2023A卷知识图谱新词挖掘。1.1 ☘️题目详情题目小华负责公司知识图谱产品现在要通过新词挖掘完善知识图谱。新词挖掘给出一个待挖掘文本内容字符串content和一个词的字符串word找到content中所有word的新词。新词使用词word的字符排列形成的字符串。请帮小华实现新词挖掘返回发现的新词的数量。输入第一行输入为待挖掘的文本内容content第二行输入为词word。输出在中找到的所有word的新词的数量。备注0 ≤ content.length ≤ 100000001 ≤ word.length ≤ 2000示例一// 输入qweebaewqd qwe// 输出2// 说明 起始索引等于 0 的子串是 qwe, 它是 word的新词。起始索引等于 6 的子串是 ewq, 它是 word的新词。示例二// 输入AASW// 输出1// 说明 需要把一个 A 更换成 D这样可以得到 ADSW 或者 DASW。示例三// 输入abab ab// 输出3// 说明 起始索引等于 0 的子串是 ab, 它是 word 的新词。起始索引等于 1 的子串是 ba, 它是 word 的新词。起始索引等于 2 的子串是 ab, 它是 word 的新词。1.2 ☘️参考解题答案解题思路由于content 中的子串都需要和单词 word 进行比较所以长度不等于rd 的子串必然不符合要求因此我们可以使用一个长度为 1en(word)的固定长度滑裔来完成新词挖掘过程。新司的定义是使用词 wrd 的字符排列形成的字符串显然和字符在子串中的出现频率有关很容易想到使用哈希表counter()来完成元素频率统计。滑窗三问**Q1:**对于每一个右指针 right 所指的元素 right_ch 做什么操作?**Q2:**什么时候要令左指针 left 右移?对于 left所指的元素 left_ch 要做什么操作?**Q3:**什么时候进行 ans 的更新?如何更新?滑窗三答**A1:**将right_ch 在窗囗对应哈希表 cnt_windows 中的统计次数 1**A2:**将left_ch 在窗囗对应哈希表 cnt windows 中的统计次数 -1如果left_ch 的出现次数降为0则删除left_ch 的键值对。**A3:**如果cnt_windows cnt_word更新答案变量Python实现# 题目2023Q1A-知识图谱新词挖掘# 分值100# 作者闭着眼睛学数理化# 算法固定滑窗# 代码看不懂的地方请直接在群上提问fromcollectionsimportCounter contentinput()wordinput()# 获得固定滑窗的长度为单词word的长度klen(word)# 初始化word对应的哈希表cnt_wordCounter(word)# 初始化第一个固定滑窗对应的哈希表cnt_windowsCounter(content[:k])# 考虑第一个滑窗的情况ansint(cnt_windowscnt_word)forright,right_chinenumerate(content[k:],k):# Q1对于每一个右指针right所指的元素right_ch做什么操作# A1将right_ch在窗口中的统计次数1cnt_windows[right_ch]1# Q2什么时候要令左指针left右移# 对于left所指的元素left_ch要做什么操作# A2在固定滑窗中left始终为right-N# 将left_ch在窗口中的统计次数-1leftright-k left_chcontent[left]cnt_windows[left_ch]-1ifcnt_windows[left_ch]0:delcnt_windows[left_ch]# Q3什么时候进行ans的更新# A3做完cnt_windows的更新后取其中最大值和当前ans比较并更新ifcnt_windowscnt_word:ans1print(ans)c实现#includeiostream#includestring#includeunordered_mapusingnamespacestd;intmain(){string content;string word;getline(cin,content);getline(cin,word);intkword.size();unordered_mapchar,intcntWord;for(charc:word){cntWord[c];}unordered_mapchar,intcntWindows;intans0;for(intright0;rightk;right){charrightChcontent[right];cntWindows[rightCh];}if(cntWindowscntWord){ans;}for(intrightk;rightcontent.size();right){charrightChcontent[right];cntWindows[rightCh];intleftright-k;charleftChcontent[left];cntWindows[leftCh]--;if(cntWindows[leftCh]0){cntWindows.erase(leftCh);}if(cntWindowscntWord){ans;}}coutansendl;return0;}java实现importjava.util.Scanner;importjava.util.HashMap;importjava.util.Map;publicclassMain{publicstaticvoidmain(String[]args){ScannerscannernewScanner(System.in);Stringcontentscanner.nextLine();Stringwordscanner.nextLine();intkword.length();MapCharacter,IntegercntWordnewHashMap();for(charc:word.toCharArray()){cntWord.put(c,cntWord.getOrDefault(c,0)1);}MapCharacter,IntegercntWindowsnewHashMap();intans0;for(intright0;rightk;right){charrightChcontent.charAt(right);cntWindows.put(rightCh,cntWindows.getOrDefault(rightCh,0)1);}if(cntWindows.equals(cntWord)){ans;}for(intrightk;rightcontent.length();right){charrightChcontent.charAt(right);cntWindows.put(rightCh,cntWindows.getOrDefault(rightCh,0)1);intleftright-k;charleftChcontent.charAt(left);cntWindows.put(leftCh,cntWindows.get(leftCh)-1);if(cntWindows.get(leftCh)0){cntWindows.remove(leftCh);}if(cntWindows.equals(cntWord)){ans;}}System.out.println(ans);}}javaScript/* JavaScript Node ACM模式 控制台输入获取 */constreadlinerequire(readline);constrlreadline.createInterface({input:process.stdin,output:process.stdout,});constlines[];rl.on(line,(line){lines.push(line);if(lines.length2){constcontentlines[0];constwordlines[1];console.log(getResult(content,word));lines.length0;}});functiongetResult(content,word){if(content.lengthword.length){return0;}constsorted_word[...word].sort().join();letans0;letmaxIcontent.length-word.length;for(leti0;imaxI;i){constsorted_substr[...content.slice(i,iword.length)].sort().join();if(sorted_substrsorted_word)ans;}returnans;}时空复杂度时间复杂度:0(N)。仅需一次遍历数组。空间复杂度0(N)。哈希表所占用空间。