请问leetcode Substring with Concatenation of All Words为什么runtime error# JobHunting - 待字闺中b*y2015-06-01 07:061 楼各位神医神户们保重
m*32015-06-01 07:062 楼在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;}