Redian新闻
>
请问leetcode Substring with Concatenation of All Words为什么runtime error
avatar
请问leetcode Substring with Concatenation of All Words为什么runtime error# JobHunting - 待字闺中
b*y
1
各位神医神户们保重
avatar
m*3
2
在local没问题,code如下,可能是什么原因呢?
vector findSubstring(string s, vector& words) {
int wordLen = words[0].size();
map expectedCount;
map actualCount;
for (int i=0; iexpectedCount[words[i]] = expectedCount[words[i]]++;
}
vector res;
for (int i=0; iint left = i;
int count = 0;
for (int j=i; j<=(int)s.length()-wordLen;j=j+wordLen) {
string str=s.substr(j, wordLen);
if (expectedCount.find(str)!=expectedCount.end()) {
actualCount[str]++;
if (actualCount[str]<=expectedCount[str]) {
count++;
} else {
while (actualCount[str]>expectedCount[str]) {
string temp = s.substr(left, wordLen);
actualCount[temp]=actualCount[temp]--;
if (actualCount[temp]count--;
left=left+wordLen;
}
}
if (count==words.size()) {
res.push_back(left);
string temp = s.substr(left, wordLen);
actualCount[temp]=actualCount[temp]--;
if (actualCount[temp]count--;
left=left+wordLen;
}
} else {
count=0;
actualCount.clear();
left=j+wordLen;
}
}
}
return res;
}
avatar
u*n
3
我们这边是:大雪封上忙
神医扫货急啊

【在 b***y 的大作中提到】
: 各位神医神户们保重
avatar
T1
4
下雪了好啊,病人都不出去shopping玩乐,在家里闷着就是进医院疗养
avatar
z*y
5
嗯,不出去扫货了

【在 b***y 的大作中提到】
: 各位神医神户们保重
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。