哪个网站上做自媒体最好,网站换新域名,泰安范镇孟庄村,免费中学网站模板力扣面试题17.18.最短超串 类似76. 用哈希表处理短数组 然后遍历长数组 找到相同元素 count– –当count0时进入循环 —— 尽可能缩小区间 class Solution {public:vectorint shortestSeq(vectorint big, vectorint small) {int nbig.si…力扣面试题17.18.最短超串 类似76. 用哈希表处理短数组 然后遍历长数组 找到相同元素 count– –当count0时进入循环 —— 尽可能缩小区间 class Solution {public:vectorint shortestSeq(vectorint big, vectorint small) {int nbig.size(),msmall.size();int st-1,edn;unordered_mapint,int cnt;int count0; //记录small中元素个数for(auto c:small){if(!cnt.count(c)) count;cnt[c] ;}for(int i0,j0;in;i){cnt[big[i]] --;if(cnt[big[i]] 0) count--;while(!count){cnt[big[j]] ;//说明当前左端点为small中元素 并且big的区间内已不包含if(cnt[big[j]] 0){count;if(ed - st i - j) st j,ed i;}j ;}}if(st -1) return {};else return {st,ed};}};